#P6578. [Ynoi2019] 魔法少女网站

[Ynoi2019] 魔法少女网站

Description

Amagai Kosame gives you a sequence of length nn. Define the sub-intervals of an interval [l,r][l,r] as all intervals of the form [l,r][l',r'], where l,rl',r' are integers and llrrl \le l' \le r' \le r.

There are mm operations:

1 x y: Modify the value at position xx to yy.

2 l r x: Query how many sub-intervals in [l,r][l,r] have maximum value less than or equal to xx.

Input Format

The first line contains two integers n,mn,m. The second line contains nn integers representing the sequence.

Then follow mm lines, each in the form 1 x y or 2 l r x, describing each operation.

Output Format

For each operation of type 2, output one line with one number, representing the answer.

6 6
1 1 4 5 1 4
1 1 4
2 1 4 2
2 1 1 4
2 1 5 4
1 5 4 
2 3 3 3
1
1
7
0

Hint

Idea: nzhtl1477, Solution: nzhtl1477, Code: ccz181078, Data: ccz181078

For 100%100\% of the testdata, n,m3×105n,m \le 3 \times 10^5, 1lrn1 \le l \le r \le n, 1x,yn1 \le x, y \le n, each element in the sequence is in [1,n][1,n], and all numbers are integers.

Translated by ChatGPT 5