# 11248: 【原1248】Square

### 题目描述

author: Lin Li 原OJ链接：https://acm.sjtu.edu.cn/OnlineJudge-old/problem/1248

## Description

1：图案按顺时针转90度。

2：图案按顺时针转180度。

3：图案按顺时针转270度。

4：水平翻转。

5：图案先水平翻转，然后再按照1到3之间的一种再次转换。

6：原图案不改变。

7：无法用以上方法得到新图案。

## Output Format

1到7之间的一个数字，表示序号最小的转换方式。

## Sample Input

3
@[email protected]
---
@@-
@[email protected]
@--
[email protected]


## Sample Output

1


## yyong119's solution

#include <iostream>
using namespace std;

int main() {

int n;
cin >> n;
char square1[n][n], square2[n][n];

for (int i = 0; i < n; ++i)
for(int j = 0; j < n; ++j)
cin >> square1[i][j];
for (int i = 0; i < n; ++i)
for (int j = 0; j < n; ++j)
cin >> square2[i][j];

int flag = 1;
for (int i = 0; i < n; ++i)
for (int j = 0; j < n; ++j)
if (square1[i][j] != square2[j][n - 1 - i])
flag = 0;
if (flag) {
cout << 1 << endl;
return 0;
}

flag = 1;
for (int i = 0; i < n; ++i)
for (int j = 0; j < n; ++j)
if (square1[i][j] != square2[n - 1 - i][n - 1 - j])
flag = 0;
if (flag) {
cout << 2 << endl;
return 0;
}

flag = 1;
for (int i = 0; i < n; ++i)
for (int j = 0; j < n; ++j)
if (square1[i][j] != square2[n - 1 - j][i])
flag = 0;
if (flag) {
cout << 3 << endl;
return 0;
}

flag=1;
for (int i = 0; i < n; ++i)
for (int j = 0; j < n; ++j)
if (square1[i][j] != square2[i][n - 1 - j])
flag = 0;
if (flag) {
cout << 4 << endl;
return 0;
}

int s1 = 1, s2 = 1, s3 = 1;
flag = 1;
for (int i = 0; i < n; ++i)
for (int j = 0; j < n; ++j) {
if (square1[i][j] != square2[j][i])
s1 = 0;
if (square1[i][j] != square2[n - 1 - i][j])
s2 = 0;
if (square1[i][j] != square2[n - 1 - j][n - 1 - i])
s3 = 0;
}
if (s1 || s2 || s3) {
cout << 5 << endl;
return 0;
}

flag = 1;
for (int i = 0; i < n; ++i)
for (int j = 0; j < n; ++j)
if (square1[i][j] != square2[i][j])
flag = 0;
if (flag)
cout << 6 << endl;
else
cout << 7 << endl;
return 0;
}


## zqy2018's solution

#include <bits/stdc++.h>
using namespace std;
char ori[12][12], now[12][12], to[12][12];
int n, tmp;
int m1(){
for(int i = 0; i < n; ++i)
for(int j = n - 1; j >= 0; --j)
now[i][n - 1 - j] = ori[j][i];
}
int m2(){
for (int i = 0; i < n; ++i)
for (int j = 0; j < n; ++j)
now[i][j] = ori[n - 1 - i][n - 1 - j];
}
int m3(){
for (int i = 0; i < n; ++i)
for (int j = 0; j < n; ++j)
now[i][j] = ori[j][n - 1 - i];
}
int m4(){
for (int i = 0; i < n; ++i)
for (int j = 0; j < n; ++j)
now[i][j] = ori[i][n - 1 - j];
}
bool judge(){
for (int i = 0; i < n; ++i)
for (int j = 0; j < n; ++j)
if (now[i][j] != to[i][j])
return false;
return true;
}
int main(){
scanf("%d", &n);
for (int i = 0; i < n; ++i)
scanf("%s", ori[i]);
for (int i = 0; i < n; ++i)
scanf("%s", to[i]);
int (*fun[])() = {m1, m2, m3, m4};
for (int i = 0; i < 6; ++i){
if (i < 4){
fun[i]();
if (judge()) {
printf("%d\n", i + 1);
return 0;
}
}else if (i == 4){
for (int k = 0; k < n; ++k)
for (int j = 0; j < (n / 2); ++j)
swap(ori[k][n-j-1], ori[k][j]);
for (int k = 0; k < 4; ++k){
fun[k]();
if (judge()) {
printf("%d\n", 5);
return 0;
}
}
for (int k = 0; k < n; ++k)
for (int j = 0; j < (n / 2); ++j)
swap(ori[k][n-j-1], ori[k][j]);
}else {
for (int i = 0; i < n; ++i)
for (int j = 0; j < n; ++j)
now[i][j] = ori[i][j];
if (judge()) {
printf("%d\n", 6);
return 0;
}
}
}
printf("7\n");
return 0;
}