9354: CCC '21 J5/S2 - Modern Art
Description
Input
The first line of input will be a positive integer $M$.
The second line of input will be a positive integer $N$.
The third line of input will be a positive integer $K$.
The remaining input will be $K$ lines giving the choices made by the artist. Each of these lines will either be R followed by a single space and then an integer which is a row number, or C followed by a single space and then an integer which is a column number. Rows are numbered top down from 1 to M. Columns are numbered left to right from 1 to N.
Output
Constraints
$K \leq 1,000,000$
up to 5,000,000 cells, and up to 1,000,000 choices by the artist.
Sample 1 Input
3
3
2
R 1
C 1
Sample 1 Output
4
After running the brush along the first row, the canvas looks like this:
GGG BBB BBB
Then after running the brush along the first column, four cells are gold in the final pattern determined by the artist's choices:
BGG GBB GBB
Sample 2 Input
4
5
7
R 3
C 1
C 2
R 2
R 2
C 1
R 4
Sample 2 Output
10
Ten cells are gold in the final pattern determined by the artist's choices:
BGBBB BGBBB GBGGG GBGGG