编程介的小学生 2017-05-01 02:31 采纳率: 20.5%
浏览 862
已采纳

Jumping Frogs

Description

Recently, Lambert has been interested in a Flash game called Jumping Frogs. The game proceeds as follows. On r-by-c grid board, there n frogs each occupying a separate cell. In each move, a frog jumps in one of the eight rectilinear and diagonal directions, flies over a neighboring frog, and lands in an empty cell at a distance of two. The frog having been flown over is then removed from the board. The goal is to remove all but one frog.

After a few attempts, Lambert finds the game too difficult for him. Therefore, he finds himself a slightly different version of the game, which allows a frog to jump to an empty cell at a distance of three without removing any other frogs from the board. To compensate such a reduction in difficulty, it is additionally required that an ending cell be specified by the player before the game starts. Upon completion of the game, the remaining frog is required to be in the ending cell. With relaxed rules of jumping, Lambert is now able to remove all but one frog. But sometimes he finds that he cannot place that remaining frog in the specified ending cell. Given a starting configuration of the game and the ending cell specified by Lambert, can you tell whether the game can be completed?

Input

The input contains multiple test cases. Each test case begins with a line containing five positive integers n, r, c, x and y (n ≤ 10; 3 ≤ r, c ≤ 10; x ≤ r; y ≤ c). Lambert specifies the cell in the x-th row and y-th column as the ending cell. Then come n lines each containing a pair of positive integers xi and yi (xi ≤ r; yi ≤ c), indicating a frog in the cell in the xi-row and yi-column. The input ends once EOF is met.

Output

For each test case, output one line containing “Yes” if the game can be completed or “No” otherwise.

Sample Input

2 3 3 1 1
2 2
3 3
2 3 3 1 1
1 1
2 2
Sample Output

Yes
No

  • 写回答

1条回答 默认 最新

报告相同问题?

悬赏问题

  • ¥15 gwas 分析-数据质控之过滤稀有突变中出现的问题
  • ¥15 没有注册类 (异常来自 HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))
  • ¥15 知识蒸馏实战博客问题
  • ¥15 用PLC设计纸袋糊底机送料系统
  • ¥15 simulink仿真中dtc控制永磁同步电机如何控制开关频率
  • ¥15 用C语言输入方程怎么
  • ¥15 网站显示不安全连接问题
  • ¥15 51单片机显示器问题
  • ¥20 关于#qt#的问题:Qt代码的移植问题
  • ¥50 求图像处理的matlab方案