/* ID: m1871091 LANG: C++11 TASK: transform */ #define _CRT_SECURE_NO_WARNINGS #define local #include<iostream> #include<cstring> #include<algorithm> using namespace std; int n; void rotate_90(char a[15][15], char b[15][15]){ for (int i = 0; i < n; i++){ for (int j = 0; j < n; j++){ b[j][n-i-1] = a[i][j]; } } } void Reflection(char a[15][15], char b[15][15]){ for (int i = 0; i < n; i++){ for (int j = 0; j < n; j++){ b[i][n-j-1] = a[i][j]; } } } bool compare_array(char a[15][15], char b[15][15]){ for (int i = 0; i < n; i++){ for (int j = 0; j < n; j++){ if (a[i][j] != b[i][j]) return false; } } return true; } int Combination(char a[15][15], char b[15][15], char c[15][15]){ char b1[15][15], b2[15][15], b3[15][15]; Reflection(a, b); rotate_90(b, b1); if (compare_array(c, b1)) return 1; rotate_90(b1, b2); if (compare_array(b2, c)) return 2; rotate_90(b2, b3); if (compare_array(c, b3)) return 3; else return 0; } int main(){ #ifdef local freopen("transform.in", "r", stdin); freopen("transform.out", "w", stdout); #endif // local cin >> n; char a[15][15], b[15][15], c[15][15]; char b1[15][15], b2[15][15], b3[15][15]; for (int i = 0; i < n; i++){ for (int j = 0; j < n; j++){ cin >> a[i][j]; } } for (int i = 0; i < n; i++){ for (int j = 0; j < n; j++){ cin >> c[i][j]; } } rotate_90(a, b); if (compare_array(c, b)){ cout << 1 << endl; return 0; } rotate_90(b, b1); if (compare_array(c, b1)){ cout << 2 << endl; return 0; } rotate_90(b1, b2); if (compare_array(b2, c)){ cout << 3 << endl; return 0; } Reflection(a, b); if (compare_array(c, b)){ cout << 4<< endl; return 0; } if (Combination(a, b, c) ) { cout << 5 << endl; return 0; } if (compare_array(c, a)){ cout << 6 << endl; return 0; } else { cout << 7 << endl; } return 0; }