编程介的小学生 2017-09-18 11:20 采纳率: 20.5%
浏览 856
已采纳

Cubic Rube

Description

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.
Input

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.
Output

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.
Sample Input

2
55551 11111
55551 11111
55551 11111
55551 11110
55552 00000
22222 33333
22222 33333
22222 33233
22222 33333
22222 33333
Sample Output

Yes
No

  • 写回答

1条回答

  • threenewbee 2017-10-03 02:53
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器