#P7707. 「Wdsr-2.7」百花齐放的太阳花田

「Wdsr-2.7」百花齐放的太阳花田

Description

At the beginning, Yuuka chooses nn flowers in the sunflower field. Each flower has a height hih_i and a type tit_i. They are arranged in a line and numbered 1,2,3n1,2,3\cdots n. Yuuka has mm operations of two kinds:

  • 1 l r x\colorbox{f0f0f0}{\verb!1 l r x!}: Consider all flowers in the interval [l,r][l,r]. Take out all flowers whose height is not greater than xx (that is, flowers with hixh_i\le x), and arrange them in order (that is, do not change their relative order in the original sequence). Then, according to their types, they can be divided into several consecutive segments (for example, $\{\underline{1,}\ \underline{2,2},\underline{1,1},\underline {3,}\ \underline{4,4,4}\}$ can be divided into 55 segments). Yuuka wants you to tell her how many segments there are in total.

  • 2 x y\colorbox{f0f0f0}{\verb!2 x y!}: Yuuka selects one flower with height xx and type yy, and appends it to the end.

Forced online.

Input Format

  • The first line contains three integers n,m,kn,m,k. The meanings of n,mn,m are as above, and kk is the forced online parameter.

  • The next two lines: the first line contains nn integers, representing {h1,h2hn}\{h_1,h_2\cdots h_n\}; the third line contains nn integers, representing the sequence {t1,t2tn}\{t_1,t_2\cdots t_n\}. Their meanings are as described above.

  • Then follow mm lines. Each line begins with an integer opop, indicating the type of this operation.

    • If op=1op = 1, then three integers l,r,xl',r',x' follow, describing one query.

    • If op=2op = 2, then two integers x,yx',y' follow, describing one modification.

  • In all operations, the real l,r,x,yl,r,x,y are obtained by XOR-ing the input values l,r,x,yl',r',x',y' with k×lastk \times last. Here, lastlast is the answer of the last query, initially 00.

Output Format

  • There are several lines. For each operation 11, output one integer per line, which is the answer.
10 10 0
6 8 5 9 6 10 2 4 8 9 
2 4 3 3 4 1 2 3 3 2 
2 2 8
1 1 4 4
2 1 6
2 10 2
1 7 9 7
2 10 8
2 8 4
2 3 10
1 5 16 5
1 4 14 7

0
2
5
5

10 20 0
2 19 13 20 7 19 17 8 15 12 
1 2 4 3 5 3 2 4 2 2 
2 9 3
2 17 3
1 1 9 15
1 1 12 3
2 15 5
1 6 13 6
2 7 1
2 20 3
2 12 1
2 10 1
1 5 9 4
1 1 7 15
2 12 4
1 12 12 14
2 7 5
1 3 18 6
1 7 7 1
2 8 5
1 6 8 10
1 14 18 4

5
1
0
0
3
0
0
0
1
0

Hint

nn' denotes the length of the sequence after all operations.

$$\def\arraystretch{1.5} \begin{array}{|c|c|c|c|}\hline \bf{Subtask} & \bm{n',m} & \textsf{\textbf{Special Property}} & \textsf{\textbf{Score}} \cr\hline 1 & 1\le n',m \le 10^3 & \text{None} & 10 \cr\hline 2 & 1\le n',m \le 3\times 10^5 & k=0 & 20\cr\hline 3 & 1\le n',m \le 3\times 10^5 & l=1 & 25\cr\hline 4 & 1\le n',m \le 10^5 & \text{None} & 15\cr\hline 5 & 1\le n',m \le 3\times 10^5 & \text{None} & 20\cr\hline 6 & \text{No special constraints} & \text{Time limit 3s, memory limit 300MB} & 10\cr\hline \end{array}$$
  • For 100%100\% of the testdata:

    1n,m5×1051 \le n',m \le 5 \times 10 ^ 5

    1hi,ti,x,y1091 \le h_i,t_i,x,y \le 10^91lrn1 \le l \le r \le n'

    1op21 \le op \le 20k1030 \le k \le 10^3

Hint: please pay attention to constant optimization.

Translated by ChatGPT 5