#P17422. [ICPC 2018 Xuzhou R] Rikka with Data Structures

    ID: 19924 远端评测题 12000ms 512MiB 尝试: 0 已通过: 0 显示难度提高+/省选− 上传者: 标签>2018线段树分块ICPC

[ICPC 2018 Xuzhou R] Rikka with Data Structures

Problem Description

As we know, Rikka is poor at data structures. Yuta is worrying about this situation, so he gives Rikka some tasks about data structures to practice. Here is one of them:

Yuta has an array AA with nn numbers, denoted by A[1],A[2],⋯ ,A[n]A[1], A[2], \cdots, A[n]. Then he makes mm operations on it. There are three types of operations:

  • 1 l r k\text{1 l r k}: for each index ii in [l,r][l, r], change the value of A[i]A[i] into (A[i]+k)(A[i] + k);
  • 2 l r k\text{2 l r k}: for each index ii in [l,r][l, r], change the value of A[i]A[i] into kk;
  • 3 l r x\text{3 l r x}: Yuta wants Rikka to count the number of different indices yy with l≤y≤rl \le y \le r such that $\max \lbrace A[\min \lbrace x, y \rbrace ], A[\min \lbrace x, y \rbrace +1], \cdots, A[\max \lbrace x, y \rbrace ] \rbrace = \max \lbrace A[x], A[y] \rbrace$.

It is too difficult for Rikka. Can you help her?

Input Format

The input contains several test cases, and the first line contains a single integer TT (1≤T≤2001 \le T \le 200), the number of test cases.

For each test case, the first line contains two integers nn (1≤n≤1051 \le n \le 10^5) and mm (1≤m≤1051 \le m \le 10^5).

The second line contains nn integers A[1],A[2],⋯ ,A[n]A[1], A[2], \cdots, A[n] (1≤A[i]≤1091 \le A[i] \le 10^9).

Then mm lines follow, each line of which describes an operation, containing four integers as mentioned above, satisfying 1≤l≤r≤n1 \le l \le r \le n, 1≤k≤1091 \le k \le 10^9 and 1≤x≤n1 \le x \le n.

The input guarantees that there are at most 1010 test cases with n>103n > 10^3 or m>103m > 10^3.

Output Format

For each query, an operation of type 33, output a single line with a single integer, the answer to this query.

1
10 10
1 3 2 5 2 3 1 6 4 5
3 5 7 8
3 5 7 4
1 1 5 2
3 1 10 4
3 1 10 8
2 8 8 8
3 1 10 8
3 1 10 4
2 4 8 1
3 1 2 10
3
3
10
7
10
8
2