#P9713. 「QFOI R1」抱抱
「QFOI R1」抱抱
Problem Description
Little R is a cute girl. She wants to hug everyone, and also share some cake with them.
The cake is a cuboid of size . Each unit cube is given a coordinate , where .
There are cake-cutting operations in total. Each operation cuts in one of the following three ways:
- Cut out the part with and give it to everyone.
- Cut out the part with and give it to everyone.
- Cut out the part with and give it to everyone.
Since she also wants to eat cake herself, she wants to know how much volume remains (not given away) after each cut.
Input Format
The first line contains four integers , representing the cake size and the number of cutting operations.
The next lines each contain two integers , meaning the -th type of operation described in the Description, with parameter .
Output Format
Output lines. Each line contains one integer, representing the volume of the remaining part.
3 3 3 2
1 2
2 1
9
6
1000000 1000000 1000000 6
1 123456
2 654321
3 233333
2 111111
1 333333
3 1000000
876544000000000000
303002853376000000
232302288589217792
232302288589217792
176680542935560631
0
Hint
Explanation for Sample .
After the first cut, all parts with are cut off. The remaining unit cubes are $(3,1,1),(3,1,2),(3,1,3),(3,2,1),(3,2,2),(3,2,3),(3,3,1),(3,3,2),(3,3,3)$, a total of cubes.
After the second cut, all parts with are cut off. The remaining unit cubes are , a total of cubes.
Explanation for Sample .
The fourth cut has no effect, because in the second cut, the part with had already been removed. At that time, there were no unit cubes with left.
Note that the parameter in each operation is an absolute coordinate decided at the beginning, and it does not change as operations proceed.
Constraints.
There are test points in total, points each.
For all testdata, it is guaranteed that , , . If , then ; if , then ; if , then .
- For test points , it is guaranteed that .
- For test points , it is guaranteed that and .
- For test points , it is guaranteed that and .
- For test points , there are no special constraints.
Translated by ChatGPT 5