CF1848A.Vika and Her Friends
入门
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Vika and her friends went shopping in a mall, which can be represented as a rectangular grid of rooms with sides of length n and m. Each room has coordinates (a,b), where 1≤a≤n,1≤b≤m. Thus we call a hall with coordinates (c,d) a neighbouring for it if ∣a−c∣+∣b−d∣=1.
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 (x,y), and her k friends are in rooms with coordinates (x1,y1), (x2,y2), ... ,(xk,yk), 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?
维卡和她的朋友们在一家商场购物,该商场可以表示为一个 n×m 的矩形房间网格。每个房间的坐标为 (a,b),其中 1≤a≤n,1≤b≤m。我们称坐标为 (c,d) 的房间是 (a,b) 的相邻房间,当且仅当 ∣a−c∣+∣b−d∣=1。
厌倦了空洞的时尚话题,维卡决定悄悄溜走而不被发现。但由于她还没来得及逛过任何一家商店,因此她并不想离开商场。过了一段时间,她的朋友们发现了维卡的失踪,并开始寻找她。
目前,维卡位于坐标为 (x,y) 的房间中,而她的 k 位朋友分别位于坐标为 (x1,y1)、(x2,y2)、…、(xk,yk) 的房间中(这些坐标可能重合)。注意:所有女孩每次只能移动到与其当前所在房间相邻的房间(即曼哈顿距离为 1 的房间)。
每一分钟内,首先维卡自主选择一个相邻房间移动;随后,每位朋友在看到维卡的选择之后,也各自选择一个相邻房间移动。
如果在一分钟结束时(即所有女孩均完成一次移动后),至少有一位朋友与维卡处于同一房间,则维卡被捕获,其余所有朋友也会立即被叫来。
请判断:维卡能否永远摆脱她那些烦人的朋友们?还是说她终究会在某一时刻被抓住,从而不得不继续聆听那些空洞的时尚话题?
输入格式
Each test consists of multiple test cases. The first line contains a single integer t (1≤t≤100) — the number of test cases. The description of the test cases follows.
The first line of each test case contains three integers n, m, k (1≤n,m,k≤100) — the sizes of the mall and the number of Vika's friends.
The second line of each test case contains a pair of integers x and y (1≤x≤n, 1≤y≤m) — the coordinates of the room where Vika is.
Each of the next k lines of each test case contains a pair of integers xi and yi (1≤xi≤n, 1≤yi≤m) — the coordinates of the room where the i-th friend is.
每个测试包含多个测试用例。第一行包含一个整数 t(1≤t≤100)—— 测试用例的数量。随后是各测试用例的描述。
每个测试用例的第一行包含三个整数 n、m、k(1≤n,m,k≤100)—— 商场的尺寸以及维卡的朋友数量。
每个测试用例的第二行包含一对整数 x 和 y(1≤x≤n,1≤y≤m)—— 维卡所在房间的坐标。
每个测试用例接下来的 k 行中,每行包含一对整数 xi 和 yi(1≤xi≤n,1≤yi≤m)—— 第 i 个朋友所在房间的坐标。
输出格式
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.
对于每个测试用例,如果维卡能够永远逃离她的朋友们,则输出 “YES”,否则输出 “NO”。
你可以以任意大小写形式输出每个字母(小写或大写)。例如,字符串 “yEs”、“yes”、“Yes” 和 “YES” 均被视为正确答案。
输入输出样例
输入#1
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
输出#1
YES NO YES NO YES YES
说明/提示
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.
在第一个测试用例中,朋友永远无法追上维卡,因为维卡总能移动到与朋友所在房间呈对角线相对的房间。
在第二个测试用例中,无论维卡前往何处,她的每位朋友都可在第一步之后抓住她。
在第三个测试用例中,维卡和她的朋友将始终处于不同的走廊中。
输入解题思路,AI测评打分。不知道怎么写?