SCC25 Contest 1 P6 - Poisonous Candies
In a wonderful act of generosity, Simon has laid out a \(R\) by \(C\) grid of unpoisoned candies for incoming trick-o-treaters. However, due to the massive expenditures required for such a grid, Simon has made a small change to his grid for his amusement. He can add antichlorobenzene to the candies - making unpoisoned candies poisoned and poisoned candies unpoisoned.
In total, Simon will make \(Q\) queries of three possible forms:
R x
: Simon adds antichlorobenzene to all candies in the \(x\)th row.C x
: Simon adds antichlorobenzene to all candies in the \(x\)th column.Q
: Simon asks for how many poisoned candies are in the grid.
Constraints
Every R x
and C x
query will have a valid x
index.
Subtask 1 [20%]
\(1 \leq R, C, Q \leq 200\)
Subtask 2 [30%]
\(1 \leq R, C \leq 10^{3}\)
\(1 \leq Q \leq 10^{5}\)
Subtask 3 [50%]
\(1 \leq R, C, Q \leq 10^{6}\)
Input Specification
The first line contains three integers, \(R\), \(C\), and \(Q\).
The next \(Q\) lines contain one valid query per line.
Output Specification
Output the answer to every query of the form Q
on its own line.
Sample Input
3 3 4
R 2
Q
C 2
Q
Sample Output
3
4
Comments