#P5608. [Ynoi2013] 文化课
[Ynoi2013] 文化课
Background
Chimuzu messed up badly in the first round of the NOI Qualifier, getting two big zeros, so he went back to study cultural classes.
He dug out a basic four-operations arithmetic practice problem... and then found that he could not do it.
So he needs your help. As a reward, he will give you points.
Advertisement at the top: would anyone like to take a look at the fusion tree I wrote?
(Actually, I also wrote about the Brodal queue.)
Problem Description
Chimuzu has a number sequence and an operator sequence . Each can only be or .
We define the weight of an interval as the result obtained by writing the string
$$a_{l}~p_{l}~a_{l+1}~p_{l+1} \cdots a_{r-1}~p_{r-1}~a_{r}$$and then evaluating it according to operator precedence.
An example is given below:
If and , then:
Chimuzu needs you to modify these two sequences and also query the weight of a given interval.
You need to maintain these operations:
Operation 1: given , set all to .
Operation 2: given , set all to , where means and means .
Operation 3: given , query the value of .
Input Format
The first line contains two integers .
The second line contains integers .
The third line contains integers , where means and means .
Then follow lines, each describing one operation.
Each operation starts with an identifier , indicating the operation type, followed by the parameters as described above.
When , input integers , meaning to set all to .
When , input integers , meaning to set all to , where means and means .
When , input integers , meaning to query the value of .
Output Format
For each operation , output line containing integer, which is the required answer.
6 6
1 3 5 7 9 11
0 1 1 0 1
3 1 6
3 3 6
1 1 2 13
2 3 4 1
3 1 6
3 3 6
205
134
45058
3465
20 20
525160717 947806001 1495853547 5283947 39115023 1008063001 397093019 1434942997 247321621 145181297 359967329 642658073 1402873249 50886569 150383317 1004954721 351661441 1660759179 48867601 1316622161
0 0 0 0 0 0 0 1 0 1 0 0 0 1 0 0 0 0 1
3 2 19
3 2 15
3 9 9
1 16 16 394339135
2 1 19 0
3 1 15
1 4 11 564942769
3 7 7
2 2 19 0
3 1 1
3 9 9
1 9 9 705415201
1 3 18 152081579
1 13 17 905666497
1 11 17 612267547
1 2 20 111949431
2 1 1 0
1 10 17 838945201
2 4 18 0
3 2 18
900803889
834560968
247321621
852589651
564942769
525160717
564942769
719106438
Hint
Sample Explanation 1
The initial two sequences and the first two operations are the example in the statement. After the fourth operation, the two sequences become:
,
$$w(1,6)=13+13\times 5\times 7\times 9\times 11=45058$$Constraints and Notes
For of the testdata, it is Sample 1, and the time limit is 1.5s.
For another of the testdata, , and the time limit is 1.5s.
For another of the testdata, there are no modification operations, and the time limit is 1.5s.
For another of the testdata, the testdata is guaranteed to be random, and the time limit is 1.5s.
For another of the testdata, there is no operation 1, and the time limit is 1.5s.
For another of the testdata, there is no operation 2, and the time limit is 1.5s.
For another of the testdata, the time limit is 5s.
For another of the testdata, the time limit is 3s.
For of the testdata, , , and both and are odd, , . Also, for all operations , it additionally holds that . The time limit is 1.5s.
Idea: Juan_feng.
Solution: nzhtl1477, ccz181078.
Code: Juan_feng, nzhtl1477, rehtorbegnaro, ccz181078.
Data: Juan_feng, nzhtl1477, rehtorbegnaro.
Translated by ChatGPT 5