Alice and the Doll

题意翻译

#### 题目大意 最近,爱丽丝得到了一个新玩偶。它甚至可以走路! 爱丽丝为玩偶建造了一个迷宫,并想对其进行测试。迷宫具有$n$行和$m$列。有$k$个障碍物,第$i$个障碍物位于单元格($x_i,y_i$)上,这意味着第$x_i$个行与第$y_i$列相交的单元格上存在一个禁止通过的障碍物。 然而,玩偶有着缺陷。在**同一**单元格(包括起始单元格)中,它最多只能笔直走或右转**一次**。它无法进入有障碍物的单元格或走出迷宫的界限之外。 现在,爱丽丝正在控制娃娃的动作。她将玩偶放入单元格($1,1$)(即迷宫的左上角)中。最初,玩偶的朝向从$(1,1)$向着$(1,m)$。她想让玩偶**恰好穿过一次所有**单元格而没有障碍,玩偶的行动可以在**任何**地方结束。爱丽丝的想法可以实现吗? #### 输入格式 第一行包含三个整数$n$,$m$和$k$,它们之间用空格($1≤n,m≤10^5,0≤k≤10^5$)隔开。$n,m$表示迷宫的长宽,$k$表示障碍物的数量。 接下来的$k$行,每行描述一个障碍物,第$i$行包含两个整数$x_i$和$y_i$,($1≤x_i≤n,1≤y_i≤m$)并用空格隔开,这些整数描述了第$i$个障碍物的位置。 数据保证在同一单元格中没有两个障碍物,并且在单元格($1,1$)中没有障碍物。 #### 输出格式 若玩偶可以按照题目中所述的规则精确地经过所有单元格(不包括有障碍的单元格),则打印“Yes”,如果不可能,请打印“No”,当然,答案不需要带引号。 ##### 样例解释 ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF1236D/a446f23c7b4fc0fe67d2e36e4d38a412a7a5c518.png) 从$(1,1)$直走,走到$(1,2)$ 从$(1,2)$直走,走到$(1,3)$ 从$(1,3)$右转,走到$(2,3)$ 从$(2,3)$直走,走到$(3,3)$ 从$(3,3)$右转,走到$(3,2)$ 从$(3,2)$直走,走到$(3,1)$

题目描述

Alice got a new doll these days. It can even walk! Alice has built a maze for the doll and wants to test it. The maze is a grid with $ n $ rows and $ m $ columns. There are $ k $ obstacles, the $ i $ -th of them is on the cell $ (x_i, y_i) $ , which means the cell in the intersection of the $ x_i $ -th row and the $ y_i $ -th column. However, the doll is clumsy in some ways. It can only walk straight or turn right at most once in the same cell (including the start cell). It cannot get into a cell with an obstacle or get out of the maze. More formally, there exist $ 4 $ directions, in which the doll can look: 1. The doll looks in the direction along the row from the first cell to the last. While moving looking in this direction the doll will move from the cell $ (x, y) $ into the cell $ (x, y + 1) $ ; 2. The doll looks in the direction along the column from the first cell to the last. While moving looking in this direction the doll will move from the cell $ (x, y) $ into the cell $ (x + 1, y) $ ; 3. The doll looks in the direction along the row from the last cell to first. While moving looking in this direction the doll will move from the cell $ (x, y) $ into the cell $ (x, y - 1) $ ; 4. The doll looks in the direction along the column from the last cell to the first. While moving looking in this direction the doll will move from the cell $ (x, y) $ into the cell $ (x - 1, y) $ . .Standing in some cell the doll can move into the cell in the direction it looks or it can turn right once. Turning right once, the doll switches it's direction by the following rules: $ 1 \to 2 $ , $ 2 \to 3 $ , $ 3 \to 4 $ , $ 4 \to 1 $ . Standing in one cell, the doll can make at most one turn right. Now Alice is controlling the doll's moves. She puts the doll in of the cell $ (1, 1) $ (the upper-left cell of the maze). Initially, the doll looks to the direction $ 1 $ , so along the row from the first cell to the last. She wants to let the doll walk across all the cells without obstacles exactly once and end in any place. Can it be achieved?

输入输出格式

输入格式


The first line contains three integers $ n $ , $ m $ and $ k $ , separated by spaces ( $ 1 \leq n,m \leq 10^5, 0 \leq k \leq 10^5 $ ) — the size of the maze and the number of obstacles. Next $ k $ lines describes the obstacles, the $ i $ -th line contains two integer numbers $ x_i $ and $ y_i $ , separated by spaces ( $ 1 \leq x_i \leq n,1 \leq y_i \leq m $ ), which describes the position of the $ i $ -th obstacle. It is guaranteed that no two obstacles are in the same cell and no obstacle is in cell $ (1, 1) $ .

输出格式


Print 'Yes' (without quotes) if the doll can walk across all the cells without obstacles exactly once by the rules, described in the statement. If it is impossible to walk across the maze by these rules print 'No' (without quotes).

输入输出样例

输入样例 #1

3 3 2
2 2
2 1

输出样例 #1

Yes

输入样例 #2

3 3 2
3 1
2 2

输出样例 #2

No

输入样例 #3

3 3 8
1 2
1 3
2 1
2 2
2 3
3 1
3 2
3 3

输出样例 #3

Yes

说明

Here is the picture of maze described in the first example: ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF1236D/a446f23c7b4fc0fe67d2e36e4d38a412a7a5c518.png)In the first example, the doll can walk in this way: - The doll is in the cell $ (1, 1) $ , looks to the direction $ 1 $ . Move straight; - The doll is in the cell $ (1, 2) $ , looks to the direction $ 1 $ . Move straight; - The doll is in the cell $ (1, 3) $ , looks to the direction $ 1 $ . Turn right; - The doll is in the cell $ (1, 3) $ , looks to the direction $ 2 $ . Move straight; - The doll is in the cell $ (2, 3) $ , looks to the direction $ 2 $ . Move straight; - The doll is in the cell $ (3, 3) $ , looks to the direction $ 2 $ . Turn right; - The doll is in the cell $ (3, 3) $ , looks to the direction $ 3 $ . Move straight; - The doll is in the cell $ (3, 2) $ , looks to the direction $ 3 $ . Move straight; - The doll is in the cell $ (3, 1) $ , looks to the direction $ 3 $ . The goal is achieved, all cells of the maze without obstacles passed exactly once.