PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#SRD0000049. Chtholly trở về nhà (Welcome home, Chtholly)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Chtholly trở về nhà (Welcome home, Chtholly)
Welcome home, Chtholly
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
There are cakes in a row, where cake needs seconds. Process operations:
1 l r x: for each in the inclusive interval, replace with only if ; leave smaller or equal values unchanged.2 l r x: count positions in the interval whose current value equals .
Indices start at , and all updates affect subsequent operations.
Input
The first line is ; the second lists . Every following operation consists of exactly four integers t l r x, where .
Output
Print one count for each type-2 operation.
Subtasks
- Subtask 1 (10 points): ; . Every value and parameter lies in .
- Subtask 2 (20 points): ; . Every value and parameter lies in .
- Subtask 3 (30 points): ; . Every value and parameter lies in .
- Subtask 4 (40 points): ; . Every value and parameter lies in .
Examples
Input
5 6
1 5 5 5 8
2 2 5 5
1 2 4 3
2 2 5 2
2 2 5 5
1 3 5 1
2 1 5 1
Output
3
3
0
3
Explanation
Initially, interval contains three fives. After 1 2 4 3, those fives become twos, so the next counts of and are and . The subsequent update reduces the three twos to ones, making the final answer .