luogu#P4969. 神秘的703
神秘的703
Background
Problem Setter: All OIers must be careful!!! Read the notes carefully.
Problem Setter: Chen_Xi.Naoh
Zero and Mike are two good friends who love traveling. One day, after going through the training of the great ZXG, they were exhausted, so they decided to go back to the hotel on the Double Ninth Festival to do problems and regain their confidence. Thus, our story begins.
Problem Description
Zero’s hotel room number is , and Mike’s hotel room number is . So when Zero and Mike want to get together to do problems, Zero needs to go from to , or Mike goes from to . When they are together, Mike will randomly choose problems from luogu . Each problem is worth points. Since Mike is very experienced, whenever he sees a problem, his brain will automatically assign it a difficulty value (trust that Mike’s judgment is always correct). Both Zero and Mike share a common talent value . Each person can only AC problems whose difficulty is within (that is, problems satisfying ). Of course, Zero and Mike’s talent value will not be very low.
In Zero’s room , there is a junior student BookCity who loves studying. While Zero and Mike are doing problems, BookCity will study their habits and cheer for them. Because of BookCity’s cheering, the difficulty of a certain problem will automatically decrease by (if , then the of this problem is set to by default). However, in room of the hotel lives a magical but evil person Guy, who can observe Zero and Mike and cast magic (because it is the Double Ninth Festival). When Zero and Mike are solving a certain problem, he can directly increase that problem’s difficulty to times its original value!!!!! Fortunately, Zero and Mike’s teacher tingtime will help them: in difficult situations, he will guide them and directly set the difficulty of a certain problem to a very low value .
For each problem they finish, Zero and Mike gain confidence corresponding to its score (they both pursue perfection: each problem is either solved correctly, or not written at all). Now you are Zero. You want to know how much confidence can be recovered if you and Mike solve problems from problem to problem (confidence calculation: number of AC problems one problem is points, and with people, they recover confidence in total).
Input Format
The first line contains two integers, representing the number of problems and the talent value .
The second line contains integers. The -th integer denotes the value of problem .
The third line contains one integer, representing the number of events .
In the next lines, each line contains a string and integers, describing a valid event:
- If , it is a
BookCityevent. The next two numbers mean setting the difficulty of problem to . - If , it is a
Guyevent. The next two numbers mean setting the difficulty of problem to . - If , it is a
tingtimeevent. The next two numbers mean setting the difficulty of problem to . - If , it is a
Zeroevent. The next two numbers represent a query: the amount of confidence recovered by solving problems from problem to problem .
It is strictly guaranteed that all events happen in order.
Output Format
For each Zero event, output one line with one number: the answer for that event.
5 5
2 3 4 5 9
5
BookCity 1 1
Guy 2 5
Zero 1 5
tingtime 5 1
Zero 1 5
1800
2400
Hint
Constraints:
- All initial difficulty values are in the range .
- Zero and Mike’s talent value is in the range .
- In
Zeroevents, are in the range , but it is not guaranteed that . - In
Guyevents, is in the range . - In
BookCityevents, is in the range . - All input data are in the range .
- Since Mike is very experienced, the values he assigns are in the range , and there are no problems with negative difficulty or difficulty (free points).
- Both and are in the range .
For of the testdata: , .
For of the testdata: , .
For of the testdata: , .
In short, all input data are guaranteed to be in the range , but intermediate computations are not guaranteed to stay within the range !!
Translated by ChatGPT 5