Bane of Arthropods

View as PDF

Submit solution

Points: 20 (partial)
Time limit: 0.6s
Memory limit: 128M

Author:
Problem type

Leon has created a cute little robot spider pet! //(::w::)\\
Instead of generating an intricate pattern for its web, it simply interweaves R rows with C columns of silk. It starts with an empty web; a full web consists of R + C 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 A to B (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 A to B (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: R (the number of rows), C (the number of columns), and Q (the number of queries).
The following Q lines each begin with a function number, F. For just F1 to F4, A and B follow.

Output Specification

For each F5 and F6, output the answer on its own line.

Constraints

1 \le F \le 6
1 \le A \le B \le R or C

Subtask Percentage Constraints
1 20 1 \le R, C, Q \le 100
2 20 1 \le R, C, Q \le 1\,000
3 60 1 \le R, C, Q \le 200\,000

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

There are no comments at the moment.