#P6781. [Ynoi2008] rupq

[Ynoi2008] rupq

Problem Description

Given a bracket sequence of length nn. Each position has a bracket aia_i, where ai=1a_i=1 means a left bracket '(', and ai=0a_i=0 means a right bracket ')'. The bracket at position ii has a weight bib_i.

For any bracket sequence, by repeatedly deleting a substring of the form '()' until no more operations can be done, you will finally get a unique sequence. This sequence is called the unmatched brackets. For example, a1=),a2=(,a3=(,a4=),a5=(a_1=')',a_2='(',a_3='(',a_4=')',a_5='(': the unmatched bracket sequence is )((')((', and the positions of these unmatched brackets are 1,2,51,2,5. The corresponding bb values are b1,b2,b5b_1,b_2,b_5.

There are mm operations, of the following three types:

1 x y: Single-point modification, i.e. ax:=1ax;bx:=ya_x:=1-a_x; b_x:=y.

2 l r: For the unmatched bracket positions in a[l..r]a[l..r], take the NAND\texttt {NAND} from left to right (3232-bit bitwise NAND; see https://en.wikipedia.org/wiki/NAND_logic), and also take the max\texttt {max} (maximum value). Output the result of xor\texttt {xor} between these two values. If the unmatched brackets form an empty sequence, then the answer for NAND\texttt {NAND} is 23212^{32}-1, and the answer for max\texttt {max} is 00.

NAND\texttt {NAND} means starting with c0=2321c_0=2^{32}-1, then in order ci=NAND(ci1,bi)c_i=\texttt {NAND}(c_{i-1},b_i). For a sequence bb with nn values, the final answer is cnc_n.

3 l r: Swap a[l..r]a[l..r] and a[r+1..n]a[r+1..n]. Do the same operation on bb.

Input Format

The first line contains two integers n,mn,m separated by spaces.

Then nn lines follow, each containing two integers separated by spaces. The ii-th line is ai,bia_i,b_i.

Then mm lines follow, each describing one operation.

Output Format

For each operation of type 22, output one line with the answer.

10 10
0 1
1 9
1 2
0 5
1 1
0 6
1 1
0 4
0 8
1 7
2 5 7
3 1 10
1 1 3
2 1 3
3 2 9
3 4 10
3 7 8
1 10 2
3 3 4
2 5 7
4294967295
4294967284
4294967281

Hint

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

For 100%100\% of the testdata,

0a[i]10 \le a[i] \le 1.

0b[i]1090 \le b[i] \le 10^9.

1n2×106,1m2×1051 \le n \le 2\times10^6,1 \le m \le 2\times10^5

Translated by ChatGPT 5