10122 - 方块转换

一块N x N(1<=N<=10)正方形的黑白瓦片的图案要被转换成新的正方形图案。写一个程序来找出将原始 图案按照以下列转换方法转换成新图案的最小方式: #1:转90度:图案按顺时针转90度。 #2:转180度:图案按顺时针转180度。 #3:转270度:图案按顺时针转270度。 #4:反射:图案在水平方向翻转(形成原图案的镜像)。 #5:组合:图案在水平方向翻转,然后按照#1-#3之一转换。 #6:不改变:原图案不改变。 #7:无效转换:无法用以上方法得到新图案。 如果有多种可用的转换方法,请选择序号最小的那个。

输入

第一行: 单独的一个整数N。 第二行到第N+1行: N行每行N个字符(不是“@”就是“-”);这是转换前的正方形。 第N+2行到第2*N+1行: N行每行N个字符(不是“@”就是“-”);这是转换后的正方形。

输出

单独的一行包括1到7之间的一个数字(在上文已描述)表明需要将转换前的正方形变为转换后的正方形的 转换方法。

样例

输入

3
@-@
---
@@-
@-@
@--
--@

输出

1

提示

A square pattern of size N x N (1 <= N <= 10) black and white square tiles is transformed into another square pattern. Write a program that will recognize the minimum transformation that has been applied to the original pattern given the following list of possible transformations:

#1: 90 Degree Rotation: The pattern was rotated clockwise 90 degrees. #2: 180 Degree Rotation: The pattern was rotated clockwise 180 degrees. #3: 270 Degree Rotation: The pattern was rotated clockwise 270 degrees. #4: Reflection: The pattern was reflected horizontally (turned into a mirror image of itself by reflecting around a vertical line in the middle of the image). #5: Combination: The pattern was reflected horizontally and then subjected to one of the rotations (#1-#3). #6: No Change: The original pattern was not changed. #7: Invalid Transformation: The new pattern was not obtained by any of the above methods. In the case that more than one transform could have been used, choose the one with the minimum number above.

PROGRAM NAME: transform INPUT FORMAT Line 1: A single integer, N
Line 2..N+1: N lines of N characters (each either @' or -'); this is the square before transformation Line N+2..2*N+1: N lines of N characters (each either @' or -'); this is the square after transformation

SAMPLE INPUT (file transform.in) 3

@-@

@@- @-@ @-- --@

OUTPUT FORMAT A single line containing the the number from 1 through 7 (described above) that categorizes the transformation required to change from the before' representation to the after' representation. SAMPLE OUTPUT (file transform.out) 1

时间限制 1 秒
内存限制 128 MB
统计
上一题 下一题