Score : $600$ points
We have a grid with $H$ horizontal rows and $W$ vertical columns. Let Square $(i,j)$ be the square at the $i$-th row and $j$-th column.
There are $M$ obstacles on this grid. The $i$-th obstacle is at Square $(X_i, Y_i)$.
We have a rook, the chess piece, on Square $(1, 1)$. In one move, it can move to the right or downward through any number of squares without obstacles.
Find the number of squares the rook can reach in two moves or less.
Input is given from Standard Input in the following format:
$H$ $W$ $M$ $X_1$ $Y_1$ $\vdots$ $X_M$ $Y_M$
Print the number of squares the rook can reach in two moves or less.
4 3 2 2 2 3 3
10
Every square without an obstacle can be reached in two moves or less.
5 4 4 3 2 3 4 4 2 5 2
14
Every square without an obstacle except $(4,4)$ and $(5,4)$ can be reached in two moves or less.
200000 200000 0
40000000000