#P11373. 「CZOI-R2」天平
「CZOI-R2」天平
Problem Description
You have weight groups, numbered from to . In the -th weight group, all weights have the same positive integer mass , and the number of weights in each weight group is unlimited.
There are operations:
I x v: Insert a new weight group after the -th weight group, where the mass of a single weight in this new group is . When , it means inserting at the very front.D x: Delete the -th weight group.A l r v: Add to the mass of the weights in all weight groups from to .Q l r v: Determine whether it is possible to measure mass using weights from weight groups to . You may use any number of weights from each group, including zero.
For operations I and D, after the operation, the indices and the value of will change automatically.
A set of weights can measure mass if and only if there exists a way to place these weights on the two sides of the balance scale such that placing one object of mass on one side can make the scale balance.
Input Format
The first line contains integers .
The second line contains integers, where the -th integer is .
The next lines each describe one operation.
Output Format
For each Q operation, output one line YES or NO, indicating whether mass can be measured.
5 5
1 10 8 4 2
I 2 1
A 1 4 4
A 2 4 4
D 5
Q 1 4 4
YES
10 10
2 2 1 4 2 10 8 7 10 6
Q 5 6 1
Q 5 7 7
I 5 1
Q 4 5 3
Q 2 9 2
A 3 5 1
Q 7 8 5
D 7
A 3 9 7
Q 3 7 6
NO
NO
NO
YES
NO
YES
Hint
[Sample Explanation]
For sample group , in the end there are weight groups, with masses respectively. Put weight from weight group 1 on the left side of the balance, and put weight from weight group 3 on the right side, then you can measure mass .

[Constraints]
This problem uses bundled testdata.
Let be the minimum value of and over all moments, and let be the maximum value of and over all moments.
- Subtask #1 (): , .
- Subtask #2 (): .
- Subtask #3 (): There are no
Ioperations and noDoperations. - Subtask #4 (): No special properties.
For of the data, , . It is guaranteed that all operations are valid, and at any moment there is at least one weight group.
Translated by ChatGPT 5