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

建议使用的浏览器:

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

3077:Recursive Ants

题目描述
In a 2^n*2^n chess board, some grids is marked visitable, and others are not. Mr. Ant is planning to visit all the visitable grids on the board, and each grid can be visited only once. Mr. Ant start from the left-top side of the board, and he should finish his journey at any grid on the edge of the board. Of course we assume that the start point of Mr. Ant is always visitable.
In every step, Mr. Ant can move from one grid to the adjacent grid (that is to say he can move up, down, left, right in four directions).
Mr. Ant’s path is defined recursively. That is to say, if Mr. Ant wants to visit a 2^k*2^k chess board, then we divided the board into four pieces, and each one has a size of 2^(k-1)*2^(k-1), in every part, Mr. Ant should visit all the grids in the four parts and then move onto another. Of course, we should divided this 2^(k-1)*2^(k-1) board into four smaller pieces and Mr. Ant’s path should be defined in these new four parts.
输入解释
The input-file consists of several test cases. There is a number n (1<= n <=7) in the beginning of each test case indicating that the width of the chess board: 2^n*2^n. Each of the next 2n lines contains a string. Character ‘1’ means visitable and ‘0’ means not. Input-file is end with an end-of-file character.
输出解释
For every case, you only need to output one line. Output “YES” if Mr. Ant can finish his journey as described above, else output “NO”.
输入样例
1
11
10
2
1100
0110
0111
0111
3
11001100
01111100
01111111
01111111
11111111
11111111
00001111
00001111
输出样例
NO
NO
YES
来自杭电HDUOJ的附加信息
Recommend lcy

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-3077

最后修改于 2020-10-25T22:59:48+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
2000/1000MS(Java/Others) 65535/65535K(Java/Others)