编程介的小学生 2017-04-11 09:46 采纳率: 20.5%
浏览 928
已采纳

Unix Robots

Wyest is fond of the game Unix Robots. It is played on a two-dimensional rectangular board. The objective of the game is to escape from a number of robots, which have been programmed with only a single objective: to kill you.

The player character and the robots start at randomly selected grids in the board. Every time the player character moves a square in any direction (horizontally, vertically, or diagonally), so does each robot, in whichever direction is the shortest way. That is, if a robot has two optimal approaches, it will first make |xrobot - xman| and |yrobot - yman| both smaller (move diagonally). (In fact there're robots moving two squares in some sets of Unix Robots, but now we're not considering them.) If the player character collides with a robot, he dies and the game ends. However, the robots are also fatal to each other - when two robots collide, they both die, leaving behind a junkheap. These junkheaps are also fatal to robots.

You can also transport into a grid in cases where moving is otherwise impossible. There're two kinds of transports, one is safe teleport, which has a limit of using, and the other is random. if you have no more safe ones, you'll have to be transported into a randomly selected location, maybe right into the path of a robot.

Generally, the player will gain one safe teleport moving onto the next level, no doubt it's too few. So the Wait button is introduced to you. If you press it, you will no longer be able to move until either all of the robots (which still move towards you) are gone, or you are killed. If you survive finally, each robot will earn you one extra safe teleports to use in future.

Now Wyest is playing the game again, and is asking you to do her a little favor. Given the situation on the board, you only need to tell her whether she can press the Wait button now.

Input

There're multiple test cases. In each test case, the first line contains two integers x and y, coordinates of the grid where the player character is. The second line of a case is an integer n, indicating the number of robots, and n lines follow, each contains two integers xi and yi, coordinates of the grid where roboti is. Then a single line containing an integer m, indicating the number of junkheaps of previous collisions on the board, and m lines follow, each contains two integers xj and yj, coordinates of the grid where junkheapj is.
0 < n <= 100, 0 <= m <= 100. All coordinates between -500000000 and 500000000, and you can safely assume that in each case, no two things are in the same grid initially.

Output

A single line for each case telling whether Wyest can Wait in the current situation, either "YES" or "NO".

Sample Input

0 0
2
3 1
3 -1
0
0 0
1
2 0
1
3 0
Sample Output

YES
NO

  • 写回答

1条回答

  • threenewbee 2017-04-28 15:49
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥15 stable diffusion
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿