#K73117. Toggle Grid Cells
Toggle Grid Cells
Toggle Grid Cells
You are given a grid with n rows and m columns. Initially, all cells in the grid are empty. You will be given q queries, each query contains a pair of integers (x, y) indicating the cell at row x and column y (1-indexed). For each query, you need to toggle the state of the cell at position (x, y). Toggling means that if the cell is empty, it becomes filled; if it is filled, it becomes empty.
After processing each query, output the total number of filled cells. Formally, if we define the filled cells as a set, after each toggle operation, print \( |S| \) (the size of the set of filled cells).
Example:
Input: 3 3 3 1 1 3 1 1 1</p>Output: 1 2 1
inputFormat
The first line contains three space-separated integers \(n\), \(m\), and \(q\), representing the number of rows, columns, and queries respectively.
Each of the following \(q\) lines contains two space-separated integers \(x\) and \(y\) representing the row and column indices of the cell to toggle.
outputFormat
For each query, print on a new line the number of filled cells after performing the toggle operation.
## sample3 3 3
1 1
3 1
1 1
1
2
1
</p>