当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。
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?
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.
For each test case, output one line containing “Yes” if the game can be completed or “No” otherwise.
2 3 3 1 1 2 2 3 3 2 3 3 1 1 1 1 2 2
Yes No
时间上限 | 内存上限 |
1000 | 131072 |