编程介的小学生 2019-04-29 23:48 采纳率: 20.5%
浏览 161

三阶方形的矩阵的算法,怎么利用C程序的语言的技术编程实现的呢?

Problem Description
Consider a cube of size 3 * 3 * 3. Let us number the 27 blocks in it as follows:
1 2 3
4 5 6
7 8 9

10 11 12
13 14 15
16 17 18

19 20 21
22 23 24
25 26 27
(The top layer is given first, followed by the middle, then the bottom one)

It is known that a strange caterpillar is stuck inside this cube. The length of its body is exactly 27, thus there is exactly one section of its body in each cell of the cube. The caterpillar's body is not necessarily straight; it may turn in any of the six directions (provided that the cell adjacent in that direction exists). You're given the information of which parts of the caterpillar's body turned in the respective cells, please find whether such a solution exists; if it does, output the lexicographically smallest one.

Input
The first line of the input contains one integer, T, the number of test cases. T lines follow, each line containing 25 integers, describing the statuses of all parts of the caterpillar's body except head and tail, in the order from head to tail; if the ith integer is non-zero, it means that the caterpillar's (i+1)th part of body turned in its cell.

Output
For each case, if a solution is found, please output three blocks in the format as indicated in the problem statement. 1 and 27 should be used to represent the head and the tail of the caterpillar, respectively. If no solution is found, please output one line containing “No solution” (without quotes).
Please follow the format as indicated in the sample output. Print a blank line after all cases except the last one.

Sample Input
2
0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

Sample Output
Case 1:
1 2 3
6 5 4
7 8 9

18 13 12
17 14 11
16 15 10

19 20 21
24 23 22
25 26 27

Case 2:
No solution

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
    • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
    • ¥15 CSAPPattacklab
    • ¥15 一直显示正在等待HID—ISP
    • ¥15 Python turtle 画图
    • ¥15 关于大棚监测的pcb板设计
    • ¥15 stm32开发clion时遇到的编译问题
    • ¥15 lna设计 源简并电感型共源放大器
    • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
    • ¥15 Vue3地图和异步函数使用