#P7346. 【DSOI 2021】归零
【DSOI 2021】归零
Description
( If you feel the statement is unclear, please visit “Input Format” to see a simplified version.)
( Please read the guarantees to ensure you can solve the problem.)
What I want to ask is only...
Suppose I have a sequence of length , indexed from , where denotes the -th number.
I will perform operations of four types, numbered in the given order:
If I have two values and , I will use shadow magic to XOR onto all such that .
At the same time, I will reflect on myself and ask for the value of in the sequence.
After many loops, I have learned that only by perfectly seizing every opportunity can I gain a greater advantage. Therefore I will compare with my expectation . If , I will loop back and execute the shadow magic operations among operations numbered .
Also, to prevent forgetting, I will loop back and execute operation number .
As you know, save points in looping cannot be interleaved, so my loops will not intersect.
Can you help me answer the questions in my mind?
Input Format
The first line contains two integers and , representing the length of the sequence and the number of operations.
The second line contains integers , representing the initial sequence.
Then follow lines, each containing some integers. Line describes operation number . The first integer is one of :
- : Read 3 integers , , . For all (that is, , … , where and ), set ( denotes XOR).
- : Read 2 integers , , and output .
- : Read 5 integers , , , , . If , execute all operations with among operations numbered ; otherwise ignore this operation. It is guaranteed that .
- : Read 2 integers , , and execute operation number . It is guaranteed that .
Because loops do not interleave, the problem guarantees:
- If , then among operations numbered , the type is definitely not or .
- Also, if , then among operations numbered , the type is definitely not or (but operation itself may be of type or , i.e., it can be called).
In mathematical language: if , then there are no or operations in ; if , then there are no or operations in .
Output Format
Output several lines.
Each line is the answer to a query of type , or the answer produced by a query operation that is invoked by a type call.
6 10
1 1 4 5 1 4
1 1 6
1 2 8
4 2
4 3
4 4
4 5
4 6
2 1
2 3
2 4
7
2
3
6 10
2 3 7 1 9 0
1 1 2
3 4 10 1 1
1 3 3
4 3
2 5
2 6
1 2 8
4 5
4 8
2 6
9
0
9
9
8
Hint
[For sample 2, the values of the sequence during each operation are given below.]
| Operation | Explanation | ||||||
|---|---|---|---|---|---|---|---|
| None | 2 | 3 | 7 | 1 | 9 | 0 | Input |
| 0 | 1 | 5 | 3 | 11 | 2 | all | |
| 2 | 3 | 7 | 1 | 9 | 0 | , perform operation | |
| 4 | 3 | both 3 | |||||
| 7 | 0 | ||||||
| Output | |||||||
| 11 | 9 | 8 | all | ||||
| Output | |||||||
| Output |
[Explanation of the “guarantees”]
For example, suppose the operation types are , , , , , . Then for , the corresponding and can only be , , because would make its range contain an operation of type . For , the corresponding can be or , because then there are no type or operations between the right side of and the left side of operation .
[Constraints]
This problem uses bundled testdata. You must pass all test points in a subtask to obtain the score of that subtask.
| Subtask | Special Property | Score |
| :----------: | :----------: |:--------:|
| 1 | Is sample | 2 pts |
| 2 | , | 8 pts |
| 3 | , | 10 pts |
| 4 | , | 10 pts |
| 5 | , , no operation | 10 pts |
| 6 | , , no operation | 10 pts |
| 7 | , , random testdata | 18 pts |
| 8 | , | 32 pts |
For of the data, it is guaranteed that , , and all values during the process and in the results are within the range of int.
Translated by ChatGPT 5
京公网安备 11011102002149号