#P6781. [Ynoi2008] rupq
[Ynoi2008] rupq
Problem Description
Given a bracket sequence of length . Each position has a bracket , where means a left bracket '(', and means a right bracket ')'. The bracket at position has a weight .
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, : the unmatched bracket sequence is , and the positions of these unmatched brackets are . The corresponding values are .
There are operations, of the following three types:
1 x y: Single-point modification, i.e. .
2 l r: For the unmatched bracket positions in , take the from left to right (-bit bitwise NAND; see https://en.wikipedia.org/wiki/NAND_logic), and also take the (maximum value). Output the result of between these two values. If the unmatched brackets form an empty sequence, then the answer for is , and the answer for is .
means starting with , then in order . For a sequence with values, the final answer is .
3 l r: Swap and . Do the same operation on .
Input Format
The first line contains two integers separated by spaces.
Then lines follow, each containing two integers separated by spaces. The -th line is .
Then lines follow, each describing one operation.
Output Format
For each operation of type , 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 of the testdata,
.
.
。
Translated by ChatGPT 5