Leon has created a cute little robot spider pet! //w\\
Instead of generating an intricate pattern for its web, it simply interweaves rows with columns of silk.
It starts with an empty web; a full web consists of strands of silk forming a grid-like pattern.
Please help implement some of its functions, and you might be rewarded (with points)!
F1: Robo-Spider generates silk somehow (don't ask me, I'm just the programmer).
It weaves in consecutive rows of silk, filling in all rows from to (inclusive), if they don't already exist.
F2: Same as F1, but for columns.
F3: Consecutive rows of silk snap (blame the chemist)!
Only existing strands of silk that make up rows to (inclusive) are affected.
F4: Same as F3, but for columns.
F5: How much of the web is exposed? Please determine the total area not covered by the web.
F6: How optimal is the web? Please determine the area of the hole with the maximum area in the web.
Input Specification
The first line contains three integers: (the number of rows), (the number of columns), and (the number of queries).
The following lines each begin with a function number, . For just F1 to F4, and follow.
Output Specification
For each F5 and F6, output the answer on its own line.
Constraints
or
Subtask | Percentage | Constraints |
---|---|---|
Sample Input
10 10 7
6
1 4 6
5
2 7 8
6
3 5 5
5
Sample Output
100
70
24
64
Diagram
A picture is worth a thousand words.
\ 1 2 3 4 5 6 7 8 9 10
1
2
3
4
5 100
6
7
8
9
10
\ 1 2 3 4 5 6 7 8 9 10
1
2 30
3
4 --------------------
5 -------------------- = 70
6 --------------------
7
8 40
9
10
\ 1 2 3 4 5 6 7 8 9 10
1 | |
2 | |
3 | |
4 ------------|-------
5 --------------|-----
6 ------------|-------
7 | |
8 24 | |
9 | |
10 | |
\ 1 2 3 4 5 6 7 8 9 10
1 | |
2 18 | | 6
3 | |
4 ------------|-------
5 6 | | 2 = 64
6 ------------|-------
7 | |
8 24 | | 8
9 | |
10 | |
Comments