迷宫的寻找的路线的问题,要求使用C语言的程序的编写的设计的代码的过程的做法的实现

Problem Description
This summer, ELT and his classmates went to Beijing for a training of coding. ELT have never been to Beijing before, so at the weekend, he together with some friends went to the National Museum, it's free for students!
The National Museum consists of many parts. One part of it is an exhibition of Ancient China From Xia Dynasty to Qing Dynasty, it needs a big room to show all the things. What's more, there exist many walls to hang pictures. The boundary of this room is walls except the entrance and exit.
With walls, an entrance and an exit, this room can be regarded as a maze. To make it simple, this room is a R*C grid, wall is constructed at some edges of grid. The entrance is always at the first row, and the exit is always at the last row, just like the picture below.
ELT can't remember his direction in maze, but he is a clever boy. He knew an algorithm called "Always Turn Right", it's procedure is as follows: at any grid of this room, if we can turn right(no wall at right side), then we must turn right; if we can't turn right but can go straight forward, then we must go forward; if we can't go forward but can turn left, then we must turn left; if we can't even turn left, we just turn backward. In the picture above, if we use this algorithm, we'll visit these grids in order: Entrance --> (0, 1) --> (0, 0) --> (0, 1) --> (0, 2) --> (1, 2) --> (1, 1) --> (1, 0) --> (2, 0) --> (1, 0) --> (1, 1) --> (2, 1) --> (2, 2) --> Exit. Very easy, doesn't it?
ELT uses "Always Turn Right" algorithm to visit this room from entrance to exit, and then from exit to entrance. He wants to know whether he walked all grids in the room. Now ELT is dizzy because the maze is too big, can you help him?
Input
First line is an integer T, means T test cases. In each test case, the first line has four numbers: R, C, Ent_Column, Exit_Column. Ent_Column is the column number of entrance; Exit_Column is the column number of exit.
Then following 2*R-1 lines, 2*i line have C-1 numbers, the j-th number shows whether there is a wall between grid(i, j) and grid(i, j+1), 2*i+1 line have C numbers, the j-th number shows whether there is a wall between grid(i, j) and grid(i+1, j). Number 1 represents a wall, 0 represents no wall.
We guarantee that there exists a path from entrance to exit.
2 <= R, C <= 500
0 <= Ent_Column, Exit_Column < C
Output
If ELT can walk all grids in the room, print one line "YES", otherwise, print one line "NO".
Sample Input
1
3 4 1 2
0 0 0
1 1 0 1
0 0 0
0 0 0 0
1 0 0
Sample Output
YES

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问

相似问题

1
QT 迷宫游戏 可视化迷宫
1
问题 C: 孤岛营救问题【队列 搜索 BFS】。
0
C++迷宫(栈实现),无法回溯
1
用java写的迷宫,能够打开自己制定的迷宫地图,并找出最短路径和遍历迷宫
1
骑士游历C语言版,用类似迷宫算法如下,求大神告知错误的地方。
2
c语言走迷宫问题提问!
0
这是我写的迷宫问题的代码,请问各位大神为什么最后输出不了迷宫通路呀
0
用Java做算法提高 学霸的迷宫
1
一个数据结构上面路径可达性判断的问题,要求采用C语言技术
0
一个迷宫是否联通的有效性的判定算法怎么实现,采用C语言编程怎么实现
0
迷宫的遍历的算法在数据结构方面的一个运用,怎么采用C程序的语言的技术设计的代码实现?
0
c语言,迷宫问题,救救孩子
2
为什么到最后一直无法输出迷宫路径?
0
迷宫的绕路的一个算法问题,如何运用C语言的程序的编写的方式实现
0
数组走到右上角时可以获得的最大金币数目,请问怎么样才能使用C语言的程序的编写的技术实现的?
0
一个迷宫的便利的典型的算法问题,怎么利用C语言程序代码思路解题的过程?
0
数字的迷宫的寻路的算法解决,怎么采用c程序的语言编写的技术实现的呢?
0
走到右上角时可以获得的最大金币数目的运算,怎么采用C程序的语言代码编写技术去实现的呢?
0
迷宫的寻找的路线的问题,要求使用C语言的程序的编写的设计的代码的过程的做法怎么才能实现的呢?
0
计算以最小化离开迷宫的预期步数,怎么才能采用C语言的程序的设计的代码的编写的过程的设计的实现的原理