#Lutece1392. Liao's Search Algorithm
Liao's Search Algorithm
Migrated from Lutece 1392 Liao's Search Algorithm
All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.
Description
Liao is a power person, he is good at anything especially Search Algorithm, his motto is “There is nothing that cannot be solved by Search once, if there is, then Search twice!” So, for any NP-hard problem, Liao can always get the best answer by Liao’s Search Algorithm. How powerful he is! . Everyone is confused with Liao’s talent, because they can’t believe that! People believe that Liao can solve NP-hard problem just depend on a secret item called 772002!
Now people want to check whether Liao is really a talent person, they request Liao to solve an easy problem, but during the solving time, Liao must take 772002 to another person.
But Liao has his own pride, he doesn’t want to solve this easy problem and you are a fan of Liao, you want help Liao to solve this problem!
The problem is a hard Data Structure problem. You are given a positive integer sequence ,,…, of length , and there are three kinds of operations you need to complete.
-
:Change to .
-
:Change into ,for all ,
-
:Query
-
= , ,
Input
The first line only contains an positive integer ( ) , represents there are test cases.
For each test case:
The first line contains two positive integers and .
The next line contains positive integer , represent . ( )
The next lines, first contains an integer , indicating the kind of operation.
If x is 1 , then three positive integers ,, . It means you need to change to . .
If x is 2 , then three positive integers ,, . It means you need to Change into ,for all .
If x is 3 , then two positive integers , . It means you need to output .
Output
For each operation 3, output one integer represent the answer.
Samples
1
5 4
1 2 3 4 5
3 1 5
1 1 3 4
2 1 4 4
3 1 4
15
8
Note
For the Sample input
The first operation is query a[1] + a[2] + a[3] + a[4] + a[5] , so you need to output 15
After the second operation, the sequence is 4 4 4 4 5
After the third operation, the sequence is 2 2 2 2 5
The forth operation is query a[1] + a[2] + a[3] + a[4] , so you need to output 8
Resources
IEEEXTREME Programming Competition