URAL1970

Vova was walking along the Statue Square (皇后像廣場) in Hong Kong, when he noticed that the square was paved with multi-colored square tiles. Vova took a careful look at the tiles and realized that they formed some picture. The tiles were large and he couldn’t look at all of them at once. Probably one should look at the tile picture from above.
Vova decided to take a photo of a (10 × 10)-tile part of a picture, but he still couldn’t cover them with one shot. Then Vova took nine photos, each of them covered a (4 × 4)-tile area of the picture (see the picture below). If we arrange the nine photos correctly, then we can restore the original 10 × 10 picture.

Unfortunately, soon after printing out the photos Vova forgot not only the arranging order of them, but the correct rotation as well. He can rotate the image on the photo by an arbitrary angle multiple of 90 degrees. Help Vova use the nine photos to restore the original 10 × 10 pattern.
Input

The input contains the nine photos Vova made. The photos are described by 4 × 4 size matrices containing integers from 0 to 99, representing the colors of the corresponding tiles. The numbers on a line are separated by spaces. Each matrix is separated from the next one by an empty line.
Output

Print the original pattern as a 10 × 10 matrix. The matrix elements in the line should be separated by spaces. If there are multiple solutions, you may print any of them. It is guaranteed that at least one solution exists.
Example

input output
1 1 9 9
1 9 1 1
9 1 1 1
9 1 1 9

9 1 1 9
9 1 1 1
9 1 1 1
9 1 1 9

9 1 1 9
9 1 1 1
1 9 1 1
1 1 9 9

9 1 1 9
1 1 1 1
1 1 1 1
9 1 1 9

9 1 1 9
1 1 1 9
1 1 9 1
9 9 1 1

9 1 1 9
1 1 1 9
1 1 1 9
9 1 1 9

9 9 1 1
1 1 9 1
1 1 1 9
9 1 1 9

9 9 9 9
1 1 1 1
1 1 1 1
9 1 1 9

9 1 1 9
1 9 9 1
1 1 1 1
9 9 9 9
1 1 9 9 9 9 9 9 1 1
1 9 1 1 1 1 1 1 9 1
9 1 1 1 1 1 1 1 1 9
9 1 1 9 1 1 9 1 1 9
9 1 1 1 1 1 1 1 1 9
9 1 1 1 1 1 1 1 1 9
9 1 1 9 1 1 9 1 1 9
9 1 1 1 9 9 1 1 1 9
1 9 1 1 1 1 1 1 9 1
1 1 9 9 9 9 9 9 1 1

这道题就是一个全排列和旋转的暴搜,我们直接写个rotate,转4次就转回来了。

Vova was walking along the Statue Square (皇后像廣場) in Hong Kong, when he noticed that the square was paved with multi-colored square tiles. Vova took a careful look at the tiles and realized that they formed some picture. The tiles were large and he couldn't look at all of them at once. Probably one should look at the tile picture from above.
Vova decided to take a photo of a (10 × 10)-tile part of a picture, but he still couldn't cover them with one shot. Then Vova took nine photos, each of them covered a (4 × 4)-tile area of the picture (see the picture below). If we arrange the nine photos correctly, then we can restore the original 10 × 10 picture.

Unfortunately, soon after printing out the photos Vova forgot not only the arranging order of them, but the correct rotation as well. He can rotate the image on the photo by an arbitrary angle multiple of 90 degrees. Help Vova use the nine photos to restore the original 10 × 10 pattern.
Input

The input contains the nine photos Vova made. The photos are described by 4 × 4 size matrices containing integers from 0 to 99, representing the colors of the corresponding tiles. The numbers on a line are separated by spaces. Each matrix is separated from the next one by an empty line.
Output

Print the original pattern as a 10 × 10 matrix. The matrix elements in the line should be separated by spaces. If there are multiple solutions, you may print any of them. It is guaranteed that at least one solution exists.
Example

input   output
1 1 9 9
1 9 1 1
9 1 1 1
9 1 1 9

9 1 1 9
9 1 1 1
9 1 1 1
9 1 1 9

9 1 1 9
9 1 1 1
1 9 1 1
1 1 9 9

9 1 1 9
1 1 1 1
1 1 1 1
9 1 1 9

9 1 1 9
1 1 1 9
1 1 9 1
9 9 1 1

9 1 1 9
1 1 1 9
1 1 1 9
9 1 1 9

9 9 1 1
1 1 9 1
1 1 1 9
9 1 1 9

9 9 9 9
1 1 1 1
1 1 1 1
9 1 1 9

9 1 1 9
1 9 9 1
1 1 1 1
9 9 9 9
1 1 9 9 9 9 9 9 1 1
1 9 1 1 1 1 1 1 9 1
9 1 1 1 1 1 1 1 1 9
9 1 1 9 1 1 9 1 1 9
9 1 1 1 1 1 1 1 1 9
9 1 1 1 1 1 1 1 1 9
9 1 1 9 1 1 9 1 1 9
9 1 1 1 9 9 1 1 1 9
1 9 1 1 1 1 1 1 9 1
1 1 9 9 9 9 9 9 1 1


这道题就是一个全排列和旋转的暴搜,我们直接写个rotate,转4次就转回来了。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值