#P7346. 【DSOI 2021】归零
【DSOI 2021】归零
Background

A chance to talk with the Witch of Greed is something rare for other people.
For Q&A, only the two of us are needed. Let us skip the extra small talk; words alone are enough.

Your thirst for knowledge, curiosity, and greed—I acknowledge them all.
Speak, what do you want to ask?
Is it about the beast created against fate to save all living beings from hunger, the Witch of Gluttony Daphne?
Is it about the one who wanted to fill the world with love and granted emotions to non-humans, the Witch of Lust Camilla?
Is it about the one who lamented that the world is full of conflict, yet healed everyone with violence, the Witch of Wrath Minerva?
Is it about the one who, just to seek peace, drove the dragon to the far side of the great waterfall, the Witch of Sloth Sekhmet?
Is it about the one who relied on being young and innocent, yet punished the world without mercy, the Witch of Pride Typhon?
Is it about the embodiment of the desire for knowledge, who sought all wisdom in the world and would not even give up the world after death, the Witch of Greed Echidna?
Or is it about the Witch of Envy , the taboo “her” , who devoured all witches as her food and became an enemy of the world?

Problem 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