| 网站首页 | 业界新闻 | 小组 | 交易 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
 买学问 - 大牛一对一辅导，有问必答 买学问 - 专业的付费知识问答平台

已结贴   问题点数：100  回复次数：16

P4 : Image Encryption
Time Limit:10000ms
Case Time Limit:1000ms
Memory Limit:256MB

Description
A fancy square image encryption algorithm works as follow:
0. consider the image as an N x N matrix
1. choose an integer k∈ {0, 1, 2, 3}
2. rotate the square image k * 90 degree clockwise
3. if N is odd stop the encryption process
4. if N is even split the image into four equal sub-squares whose length is N / 2 and encrypt them recursively starting from step 0
Apparently different choices of the k serie result in different encrypted images. Given two images A and B, your task is to find out whether it is POSSIBLE that B is encrypted from A. B is possibly encrypted from A if there is a choice of k serie that encrypt A into B.

Input
Input may contains multiple test cases.
The first line of the input contains an integer T(1 <= T <= 10) which is the number of test cases.
The first line of each testcase is an integer N, the length of the side of the images A and B.
The following N lines each contain N integers, indicating the image A.
The next following N lines each contain N integers, indicating the image B.
For 20% of the data, 1 <= n <= 15
For 100% of the data, 1 <= n <= 100, 0 <= Aij, Bij <= 100000000

Output
For each testcase output Yes or No according to whether it is possible that B is encrypted from A.

Sample Input
3
2
12
34
31
42
2
12
43
31
42
4
4123
1234
2341
3412
3441
2312
1443
2132

Sample Output
Yes
No
Yes

得分:0

0.考虑图像为 N x N 矩阵
1.选择整数 k∈ {0，1，2，3}
2.顺时针方向旋转图像 k * 90 度
3.如果 N 是奇数则停止加密过程
4.如果 N 是偶数，则将图像分割成四个相等的子正方形，从步骤0开始递归加密

1 <= N <= 100, 0 <= Aij, Bij <= 100000000

Sample Input
3
2
12
34
31
42
2
12
43
31
42
4
4123
1234
2341
3412
3441
2312
1443
2132

Yes
No
Yes

[ 本帖最后由 rjsp 于 2015-9-30 15:52 编辑 ]
得分:13

得分:13

1 <= N <= 100, 0 <= Aij, Bij <= 100000000

得分:0

得分:13

得分:13

得分:13

得分:0

得分:13

• 17
• 1/2页
• 1
• 2