#P7708. 「Wdsr-2.7」八云蓝自动机 Ⅰ
「Wdsr-2.7」八云蓝自动机 Ⅰ
Description
The Yakumo Ran Automaton maintains a sequence of length , where each element has an initial value. The automaton supports the following three operations:
-
: Modify to .
-
: Swap the values of and .
-
: Query the value of .
To test the efficiency of the Yakumo Ran Automaton, Yukari needs to run a huge number of tests. To generate all operations for each test, Yukari constructed an operation sequence of length , where each element of is one operation that the automaton can execute.
Yukari will conduct a total of tests. In each test, Yukari gives a pair , meaning that the automaton should execute in order the operations . Of course, Yukari does not want the output to be too long, so for each test, you only need to tell her the sum of the results of all operation within these operations. Note: any two tests do not affect each other. After each test, the sequence will return to its initial state.
Also, Yukari does not want to trouble you with extremely large numbers, so you only need to take the answer modulo (i.e., natural overflow of ).
Input Format
-
The first line contains two integers , as described above.
-
The second line contains integers, representing the initial values of sequence .
-
The next lines describe the operation sequence . For each operation, an integer comes first to describe the type of the operation.
-
If , the next two integers are , describing an operation .
-
If , the next two integers are , describing an operation .
-
If , the next integer is , describing an operation .
-
-
The next line contains an integer , meaning the total number of tests initiated by Yakumo Yukari.
-
The next lines each contain two integers , describing one test. The execution method is as stated above.
Output Format
- Output lines. Each line contains one integer, representing the result of that test.
10 10
2 3 4 8 7 4 8 4 1 2
3 5
2 8 7
1 3 6
1 2 10
2 2 4
3 6
2 8 2
1 8 7
3 7
3 10
10
5 10
1 7
8 10
1 10
9 10
2 9
5 5
8 9
1 9
2 7
14
11
10
17
10
8
0
8
15
4
Hint
Constraints and Notes
$$\def\arraystretch {1.5}\begin{array}{|c|c|c|c|}\hline \textbf{Subtask} & \bm{n,m,q} & \textbf{Special Property} & \textbf{Score}\cr\hline 1 & 1\le n,m,q\le 10^3 & \text{None} & 10 \cr\hline 2 & \text{No special limits} & \text{No operation 1} & 20\cr\hline 3 & \text{No special limits} & \text{No operation 2} & 20\cr\hline 4 & \text{No special limits} & \text{Number of operation 3}\le 10 & 20 \cr\hline 5 & \text{No special limits}& \text{None}& 30 \cr\hline \end{array}$$-
For of the testdata, it holds that:
-
.
-
$1 \le a_i, k \le 10^9; 1 \le op \le 3; 1 \le x, y \le n; x \neq y$.
-
.
-
Translated by ChatGPT 5
京公网安备 11011102002149号