1025. Cubic Rube

单点时限: 2.0 sec

内存限制: 256 MB

Working in a Rubik’s Cube factory has always been your dream job, but you’re a clumsy rube. Now you’re trying to invent a new variation, a 5x5x5 Rubik’s Cube! You just walked into the research lab with a working prototype and accidentally dropped it, breaking it into 2 pieces. You have one piece in your left hand and are trying to find the other. Unfortunately, the floor is littered with parts from previous attempts, making it difficult to find the missing piece. Luckily, you know how to program…

Given two solids composed of unit cubes, determine if they can be fit together to form a solid 5x5x5 cube.

输入格式

The first line contains a single integer n indicating the number of data sets. The following lines contain the data sets.

Each data set will show side-by-side top-down views of each of the solids as a 5x5 array of numbers 0-9. Each number represents the height of the solid at that point (the number of unit cubes stacked at that point). If the height is 0, there is no solid present at that point. This is similar to providing a topographical map of each solid, and it is valid to assume that there are no gaps “under” any part of a solid that cannot be seen.

Note that each solid will be connected (i.e., a single piece) and may require translations (not just rotations) to join with a compatible solid.

输出格式

For each data set, print, “Yes” if a solid 5x5x5 cube can be formed by fitting together the two halves, and print, “No” if a cube cannot be formed. Each word should appear on its own line.

样例

Input
2
55551 11111
55551 11111
55551 11111
55551 11110
55552 00000
22222 33333
22222 33333
22222 33233
22222 33333
22222 33333
Output
Yes
No

7 人解决,15 人已尝试。

9 份提交通过,共有 51 份提交。

7.6 EMB 奖励。

创建: 19 年,8 月前.

修改: 7 年,4 月前.

最后提交: 1 年,6 月前.

来源: South Central USA 2004

题目标签