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 703703, and Mike’s hotel room number is 704704. So when Zero and Mike want to get together to do problems, Zero needs to go from 703703 to 704704, or Mike goes from 704704 to 703703. When they are together, Mike will randomly choose nn problems from luogu . Each problem is worth 300300 points. Since Mike is very experienced, whenever he sees a problem, his brain will automatically assign it a difficulty value hardhard (trust that Mike’s judgment is always correct). Both Zero and Mike share a common talent value TalentTalent. Each person can only AC problems whose difficulty is within TalentTalent (that is, problems satisfying hardTalenthard \le Talent). Of course, Zero and Mike’s talent value will not be very low.

In Zero’s room 703703, 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 dd (if hardd0hard - d \le 0, then the hardhard of this problem is set to 11 by default). However, in room 123123 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 hardhard to ss 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 xx.

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 ConfidenceConfidence can be recovered if you and Mike solve problems from problem aa to problem bb (confidence calculation: Confidence=600×Confidence = 600 \times number of AC problems \Longrightarrow one problem is 300300 points, and with 22 people, they recover 600600 confidence in total).

Input Format

The first line contains two integers, representing the number of problems nn and the talent value TalentTalent.

The second line contains nn integers. The ii-th integer denotes the hardhard value of problem ii.

The third line contains one integer, representing the number of events mm.

In the next mm lines, each line contains a string SS and 22 integers, describing a valid event:

  • If S=BookCityS=\texttt{BookCity}, it is a BookCity event. The next two numbers i,di,d mean setting the difficulty hardihard_i of problem ii to max(hardid,1)\max(hard_i-d,1).
  • If S=GuyS=\texttt{Guy}, it is a Guy event. The next two numbers i,di,d mean setting the difficulty hardihard_i of problem ii to hardi×dhard_i \times d.
  • If S=tingtimeS=\texttt{tingtime}, it is a tingtime event. The next two numbers i,di,d mean setting the difficulty hardihard_i of problem ii to dd.
  • If S=ZeroS=\texttt{Zero}, it is a Zero event. The next two numbers a,ba,b represent a query: the amount of confidence ConfidenceConfidence recovered by solving problems from problem aa to problem bb.

It is strictly guaranteed that all events happen in order.

Output Format

For each Zero event, output one line with one number: the answer ConfidenceConfidence 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 hardhard are in the range [0,2311][0,2^{31}-1].
  • Zero and Mike’s talent value TalentTalent is in the range [0,2311][0,2^{31}-1].
  • In Zero events, a,ba,b are in the range [0,2311][0,2^{31}-1], but it is not guaranteed that a<ba<b.
  • In Guy events, dd is in the range [0,2311][0,2^{31}-1].
  • In BookCity events, dd is in the range [0,2311][0,2^{31}-1].
  • All input data are in the range [0,2311][0,2^{31}-1].
  • Since Mike is very experienced, the hardhard values he assigns are in the range [0,2311][0,2^{31}-1], and there are no problems with negative difficulty or difficulty 00 (free points).
  • Both nn and mm are in the range [0,2311][0,2^{31}-1].

For 30%30\% of the testdata: 0n5×1030 \leqslant n \leqslant 5\times 10^3, m5×103m \leqslant 5\times 10^3.

For 50%50\% of the testdata: 0n5×1040 \leqslant n \leqslant 5\times 10^4, m5×104m \leqslant 5\times 10^4.

For 100%100\% of the testdata: 0n5×1050 \leqslant n \leqslant 5\times 10^5, m5×105m \leqslant 5\times 10^5.

In short, all input data are guaranteed to be in the range [0,2311][0,2^{31}-1], but intermediate computations are not guaranteed to stay within the range [0,2631][0,2^{63}-1]!!

Translated by ChatGPT 5