A coastal map is a grid of R rows and C columns, initially all water. A sequence of k reclamation operations each turns one cell into land, given by its 0-indexed row r and column c. An island is a maximal group of land cells connected 4-directionally (up, down, left, right).
After each operation, report the current number of islands. If an operation targets a cell that is already land, the island count is unchanged (but you still report it for that step).
Input format
- Line 1: three integers
R,C,k. - Next
klines: two integersrandc(0-indexed,0 <= r < R,0 <= c < C), the cell reclaimed at that step.
Output format
One line with k space-separated integers: the island count after each operation, in order.
Constraints
- 1 <= R, C <= 1000
- 1 <= k <= 100000
- 0 <= r < R and 0 <= c < C