Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
Statistical Charts
Submit Problem
Online Status
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Jumping Frogs
Time Limit: 1000MSMemory Limit: 131072K
Total Submissions: 203Accepted: 43


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; xr; yc). 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 (xir; yic), 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.

Sample Input

2 3 3 1 1
2 2
3 3
2 3 3 1 1
1 1
2 2

Sample Output



[Submit]   [Go Back]   [Status]   [Discuss]

Home Page   Go Back  To top

All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator