Problem Statement
There is an $H \times W$ grid. Let $(i,j)$ denote the cell at the $i$-th row $(1\le i\le H)$ from the top and $j$-th column $(1\le j\le W)$ from the left.
Each cell in the grid either has an obstacle placed on it or has nothing placed on it. There are $K$ cells with obstacles: cells $(r_1,c_1),(r_2,c_2),\ldots,(r_K,c_K)$.
Takahashi is initially at cell $(1,1)$ and wants to reach cell $(H,W)$ by repeatedly moving to an adjacent cell (up, down, left, right) that has nothing placed on it.
More precisely, he can repeat the following operation as many times as he likes:
- Choose one of the following four operations and perform the chosen operation:
- If
$1\lt i$and cell$(i-1,j)$has nothing placed on it, move to cell$(i-1,j)$. Otherwise, do not move.- If
$1\lt j$and cell$(i,j-1)$has nothing placed on it, move to cell$(i,j-1)$. Otherwise, do not move. - If
$i\lt H$and cell$(i+1,j)$has nothing placed on it, move to cell$(i+1,j)$. Otherwise, do not move. - If
$j\lt W$and cell$(i,j+1)$has nothing placed on it, move to cell$(i,j+1)$. Otherwise, do not move.
- If
Determine whether he can move from cell $(1,1)$ to cell $(H,W)$.
Constraints
$1\le H\le2\times10^5$$1\le W\le2\times10^5$$0\le K\le2\times10^5$$1\le r_i\le H\ (1\le i\le K)$$1\le c_i\le W\ (1\le i\le K)$$(r_i,c_i)\ne(1,1)\ (1\le i\le K)$$(r_i,c_i)\ne(H,W)\ (1\le i\le K)$$(r_i,c_i)\ne(r_j,c_j)\ (1\le i\lt j\le K)$- All input values are integers.
Input
The input is given from standard input in the following format:
H W K
r_1 c_1
r_2 c_2
\vdots
r_K c_K
Output
If Takahashi can move from cell $(1,1)$ to cell $(H,W)$ by repeating the operation described in the problem, print Yes; otherwise, print No.
样例
4 5 5
1 4
2 3
3 2
3 4
4 2
No
2 7 3
1 2
2 4
1 6
Yes
1 1 0
Yes
10 12 20
8 3
1 11
6 4
3 7
10 4
5 7
4 7
5 5
4 3
6 1
1 6
2 7
6 7
1 3
6 3
2 12
9 6
7 3
3 11
9 7
Yes
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。