当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

1535:Forgetful

题目描述
Each Sunday Mrs. Mahtaj who is an old woman goes to David Church and after the Sunday pray she comes back home. The traffic center has a complicated rule for closing crossroads that Mrs. Mahtaj can't understand. She is a forgetful woman who can only memorize the path from her house to church. The streets of her city are vertical or horizontal, the same as a grid with the squares of the same size. So she memorizes a path by a string of F (Forward), B (Backward), L (Left) and R (Right). For example, if there is no closed crossroad and Mahtaj is in crossroad (1,0) and faces east, if the string is BRFRLFL she reaches the crossroad (0,4). His son, Khashayar, decides to help her finding a path that can be used both for going from their house to the church and for coming back from the church to their house and does not pass any closed crossroad. I.e. Mahtaj should be able to go from her house to the church and from the church to her house by just one string. Help Khashayar to find such a path. When Mrs. Mahtaj starts the path from her house, she faces east and when she starts from the church she faces west.
输入解释
The input consists of several test cases. Each test case begins with a line containing m and n, the number of vertical and horizontal lines (streets) in the grid, which are in range 1 to 100. The second line of a test case contains two pairs of integer, which are x and y coordinates of the source (Mrs. Mahtaj's house) and x and y coordinates of the destination (David church). The horizontal and vertical lines in the grid are indexed from left to right and bottom to up from 0, so coordinates can be expressed using the indices. The third line of a test case contains a single numbe r N, which is the number of closed crossroads. It follows by N lines that each line contains x and y coordinates of a closed crossroad. The test case with m=n=0 indicates the end of the input file.
输出解释
The output for each test case is "YES" if there is such path and otherwise "NO". Output for each test case must be written on a separate line and the test case with m=n=0 has no output.
输入样例
3 3
0 0 2 2
2
1 2
2 1
6 5
0 0 5 4
5
3 0 
3 2
2 2
0 2
5 2 
0 0
输出样例
NO
YES

该题目是Virtual Judge题目,来自 北京大学POJ

源链接: POJ-1535

最后修改于 2020-10-29T06:06:35+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
1000 10000