#P4883. mzf的考验
mzf的考验
Description
The Eight Trigrams are Qian, Kun, Zhen, Xun, Kan, Li, Gen, and Dui. Combining them in pairs, one on top and one below, forms the sixty-four hexagrams. Each hexagram has six lines, making a total of 384 lines. Lines are divided into yin and yang. A yang line is strong, and a yin line is soft. The world is vast, and anything can happen. All kinds of strange things come from here. After thoroughly studying the I Ching, drew strange patterns. He said they were a stronger divination system improved by him. Each pattern has 20 rows. Each row is either a yin line or a yang line . As , we can view each hexagram as a binary string. He drew these patterns on talismans, and then performed operations:
Operation 1: Reverse the patterns in interval , for example, becomes .
Operation 2: draws a new hexagram, and XORs all hexagrams in with this newly drawn hexagram.
Operation 3: asks other people in the computer room for the sum of the weights (values) of the binary numbers represented by the hexagrams in .
If we cannot correctly answer every Operation , then the feng shui layout of the computer room will change, and we will all...!
Since , in his madness, tied us all up, we can only beg you to help us solve this problem.
Input Format
The first line contains two positive integers: , ( is the length of the sequence, and is the number of operations).
The second line contains positive integers: (each hexagram is given in decimal).
Next lines: each line starts with a positive integer indicating the operation type.
- : two positive integers: . Please reverse interval .
- : three positive integers: . Please XOR every hexagram in with hexagram . ()
- : two positive integers: . Please query the sum of hexagram weights in interval .
Output Format
For each case of , output one line with the answer.
8 9
4 6 2 1 7 9 10 2
1 1 4
3 1 6
2 4 5 2
3 1 6
2 1 5 8
3 1 6
2 5 7 10
3 4 7
3 1 8
29
29
69
24
59
Hint
For of the testdata, , .
For another of the testdata, there is no Operation .
For another of the testdata, it is guaranteed that is a power of , and in Operation , it is guaranteed that , , where can be any values.
For of the testdata, , , , .
Translated by ChatGPT 5
京公网安备 11011102002149号