微软2015校招题
先贴原文,稍后翻译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