P9023 [CCC 2021 J5/S2] Modern Art

Description

Maintain a $01$ matrix, where the initial matrix is all $0$. Each operation flips one row or one column ($0$ becomes $1$, and $1$ becomes $0$). Output how many $1$'s there are in the end.

Input Format

The first line contains $M$, the number of rows of the matrix. The second line contains $N$, the number of columns of the matrix. The third line contains $K$, the number of operations. The next $K$ lines each contain one character and one number. The character `R` means operating on a row, and `C` means a column. The number indicates which row or which column.

Output Format

One line with one number, representing the final number of $1$'s.

Explanation/Hint

Sample explanation: ``` 011 01000 100 01000 100 10111 10111 ``` Constraints: $$1 \leq M\times N\leq 5000000,1 \leq K\leq 1000000$$ Translated from [CCC2021 J5/S2](https://cemc.math.uwaterloo.ca/contests/computing/past_ccc_contests/2021/ccc/juniorEF.pdf)。 Translated by ChatGPT 5