#P7759. [COCI 2012/2013 #3] PROCESOR
[COCI 2012/2013 #3] PROCESOR
Description
Mirko received an interesting assignment: to design his own small processor. This processor has registers numbered from to . Each register stores an unsigned -bit integer in binary form (possible values are in ).
In addition, this processor is required to support the following two operations:
1 k m: Move the last bits of the binary representation of the number in register to the very front as a whole, and then write the resulting new number back into register . For example:
2 k l: Compute the XOR of the number in register and the number in register , and output the result to the system. For example:
Only after building the processor model did Mirko realize that he forgot to implement an operation to read the contents of a register. Therefore, the only thing he can do now is to execute operations and many times, and infer the register contents from the results. After executing a sequence of commands, he asks you to help him derive a set of initial register contents that is consistent with the obtained results.
If there are multiple possible sets of initial register states, you need to find the lexicographically smallest set (if two sets have equal values in the first registers but different values in register , then the lexicographically smaller set is the one with the smaller value in register ).
Input Format
The input consists of multiple lines.
The first line contains two integers , representing the total number of registers and the number of operations.
The next lines describe each operation. For an operation, first read a line with three integers , representing the operation type and its two parameters. If , then read one more line containing one integer, which is the result produced by the operation on the previous line, and then proceed to the next operation on the following line. Otherwise, proceed directly to the next operation on the next line.
If you cannot understand the input format well, please refer to the sample to better understand this part.
Output Format
If there is no set of initial register contents consistent with the input, output a single line with the integer . Otherwise, output one line with integers, where the -th integer is the number initially stored in register .
3 3
2 1 2
1
2 1 3
2
2 2 3
3
0 1 2
4 6
2 4 2
3
2 4 1
6
1 3 1
2 3 1
2
1 2 2
2 2 3
7
5 0 14 3
5 6
2 4 2
10
2 5 3
2
2 2 3
1
2 1 4
3
1 3 1
2 3 4
2147483663
15 6 7 12 5
Hint
Constraints
For of the testdata, .
For all testdata, , . Also:
- When , , .
- When , .
Source
This problem is from COCI 2012-2013 CONTEST 3 T6 PROCESOR. Using the original testdata configuration, the full score is .
Translated and organized by Eason_AC.
Translated by ChatGPT 5
京公网安备 11011102002149号