编程介的小学生 2017-08-22 17:09 采纳率: 20.5%
浏览 767
已采纳

Puzzle

Little Georgie likes puzzles very much. Recently he has found a wooden triangle in the box with old toys. The side of the triangle is n inches long. The triangle is divided into n2 unit triangles with lines drawn on his surface.

The interesting fact about that triangle is that it is not solid - it consists of two parts. Each of the parts is a connected set of unit triangles. Georgie has put his triangle onto the table and now wonders whether he can separate the parts. He wants to separate them without taking any part of the triangle off the table, just moving the parts by the table surface. The triangle has a small but non-zero thickness, so while being moved the parts must not intersect.

For example, if the triangle is divided into parts as it is shown on the top picture below, Georgie can separate the parts the way he wants. However in the case displayed on the bottom picture, he cannot separate the parts without lifting one of them.

Help Georgie to determine whether he can separate the parts moving them by the surface of the table.

Two puzzles corresponding the samples

Input

Input file contains one or more testcases. The first line of each testcase contains n (2 <= n <= 50). Next n lines contain the description of the triangle, i-th of these lines contains 2i - 1 characters, describing unit triangles in the i-th row, from left to right. Character '0' means that the triangle belongs to the first part of the main triangle, '1' means that it belongs to the second one.

Testcase with n = 0 designates the end of the test data, this testcase must not be processed. There is no blank line in the input file.

Output

For each puzzle output the line with its number followed by the line that states whether the parts can be separated. Do not output any blank lines.

Sample Input

6
0
001
00011
0000011
000111111
00111111111
6
0
001
00111
0011011
000000111
00111111111
0

Sample Output

Puzzle 1
Parts can be separated
Puzzle 2
Parts cannot be separated

  • 写回答

2条回答 默认 最新

  • threenewbee 2017-08-27 14:52
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥50 易语言把MYSQL数据库中的数据添加至组合框
  • ¥20 求数据集和代码#有偿答复
  • ¥15 关于下拉菜单选项关联的问题
  • ¥20 java-OJ-健康体检
  • ¥15 rs485的上拉下拉,不会对a-b<-200mv有影响吗,就是接受时,对判断逻辑0有影响吗
  • ¥15 使用phpstudy在云服务器上搭建个人网站
  • ¥15 应该如何判断含间隙的曲柄摇杆机构,轴与轴承是否发生了碰撞?
  • ¥15 vue3+express部署到nginx
  • ¥20 搭建pt1000三线制高精度测温电路
  • ¥15 使用Jdk8自带的算法,和Jdk11自带的加密结果会一样吗,不一样的话有什么解决方案,Jdk不能升级的情况