#P4117. [Ynoi2018] 五彩斑斓的世界

    ID: 3051 远端评测题 7500ms 64MiB 尝试: 0 已通过: 0 难度: 9 上传者: 标签>2018并查集O2优化块状链表,块状数组,分块Ynoi

[Ynoi2018] 五彩斑斓的世界

Description

Erjiedang Zhenhong gives you a sequence aa of length nn, with mm operations.

  1. For every number greater than xx in the interval [l,r][l,r], subtract xx from it.
  2. Query the number of occurrences of xx in the interval [l,r][l,r].

Input Format

The first line contains two integers nn and mm.

The second line contains nn integers representing the sequence aa.

Then follow mm lines, each containing four integers:

  • 1 l r x: For all numbers greater than xx in [l,r][l,r], subtract xx.
  • 2 l r x: Query the number of occurrences of xx in $[l,r]`.

Output Format

For each type-2 query, output one integer representing the answer.

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
3
3
0
3

Hint

Idea: nzhtl1477, Solution: nzhtl1477, Code: nzhtl1477, Data: nzhtl1477.

For 100%100\% of the testdata, 1n1061 \le n \le 10^6, 1m5×1051 \le m \le 5 \times 10^5, 1lrn1 \le l \le r \le n, 0ai,x105+10 \le a_i, x \le 10^5 + 1.

By nzhtl1477.

Translated by ChatGPT 5