No.1338 Giant Class
Problem Statement
Vil is 160cm tall, but all of his classmates are at least 170km tall. Since he cannot see the blackboard if he sits behind such a tall classmate, the seats Vil can sit in within the classroom are limited.
In the classroom, a total of $H \times W$ desks are arranged in $H$ rows and $W$ columns, and initially nobody is there. From now on, $Q$ students will arrive at school one after another. Denoting the desk in the $y$-th row from the front and the $x$-th column from the left as $(y,x)$, the $i$-th student sits at $(Y_i,X_i)$.
Find the number of seats Vil can sit in immediately after each student takes a seat. Here, Vil can sit at $(y,x)$ if and only if, at that moment, no student is sitting at any of $(h,x)(1 \le h \le y)$.
Input
$H\ W\ Q$ $Y_1\ X_1$ $Y_2\ X_2$ $\vdots$ $Y_Q\ X_Q$
- All inputs are integers.
- $1 \le H,W \le 10^9$
- $1 \le Q \le \min(H \times W,10^5)$
- $1 \le Y_i \le H$
- $1 \le X_i \le W$
- If $i \neq j $, then $(Y_i,X_i) \neq (Y_j,X_j)$
Output
Output $Q$ lines.
On the $i(1 \le i \le Q)$-th line, output the number of seats Vil can sit in immediately after the $i$-th student takes a seat, followed by a newline.
Sample
Sample 1
Input
3 3 3 1 1 2 3 3 1
Output
6 4 4
Seats Vil can sit in are shown as ., and seats he cannot sit in are shown as #.
The $1$-st student sits at $(1,1)$. Immediately after this, the seats Vil can sit in are the $6$ seats $(1,2),(1,3),(2,2),(2,3),(3,2),(3,3)$.
#.. #.. #..
The $2$-nd student sits at $(2,3)$. Immediately after this, the seats Vil can sit in are the $4$ seats $(1,2),(1,3),(2,2),(3,2)$.
#.. #.# #.#
The $3$-rd student sits at $(3,1)$. The seats Vil can sit in do not change immediately after this. Note that students other than Vil have no height-based restrictions on where they can sit.
#.. #.# #.#
Sample 2
Input
8 9 7 4 6 6 5 2 3 3 5 5 6 2 5 1 5
Output
67 64 57 54 54 53 52
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
QCFium