欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1848A.Vika and Her Friends
Vika and Her Friends
Vika and her friends went shopping in a mall, which can be represented as a rectangular grid of rooms with sides of length and . Each room has coordinates , where . Thus we call a hall with coordinates a neighbouring for it if .
Tired of empty fashion talks, Vika decided to sneak away unnoticed. But since she hasn't had a chance to visit one of the shops yet, she doesn't want to leave the mall. After a while, her friends noticed Vika's disappearance and started looking for her.
Currently, Vika is in a room with coordinates , and her friends are in rooms with coordinates , , ... , respectively. The coordinates can coincide. Note that all the girls must move to the neighbouring rooms.
Every minute, first Vika moves to one of the adjacent to the side rooms of her choice, and then each friend (seeing Vika's choice) also chooses one of the adjacent rooms to move to.
If at the end of the minute (that is, after all the girls have moved on to the neighbouring rooms) at least one friend is in the same room as Vika, she is caught and all the other friends are called.
Tell us, can Vika run away from her annoying friends forever, or will she have to continue listening to empty fashion talks after some time?
Input
Each test consists of multiple test cases. The first line contains a single integer () — the number of test cases. The description of the test cases follows.
The first line of each test case contains three integers , , () — the sizes of the mall and the number of Vika's friends.
The second line of each test case contains a pair of integers and (, ) — the coordinates of the room where Vika is.
Each of the next lines of each test case contains a pair of integers and (, ) — the coordinates of the room where the -th friend is.
Output
For each test case, output "YES" if Vika can run away from her friends forever, otherwise output "NO".
You can output each letter in any case (lowercase or uppercase). For example, the strings "yEs", "yes", "Yes", and "YES" will be accepted as a positive answer.
Note
In the first test case, the friend will never catch up with Vika, because Vika can always move to the room diagonally opposite to the one where the friend is.
In the second test case, no matter where Vika goes, each of her friends can catch her after the first move.
In the third test case, Vika and her friend will always be in different halls.
Samples
6
2 2 1
1 1
1 2
2 2 2
1 1
2 2
2 2
1 2 1
1 1
1 2
5 5 4
3 3
1 1
1 5
5 1
5 5
2 2 2
1 1
2 1
1 2
3 4 1
1 2
3 3
YES
NO
YES
NO
YES
YES
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |