https://www.luogu.org/problemnew/show/P1205
题解:

/*
*@Author:   STZG
*@Language: C++
*/
#include <bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<string>
#include<vector>
#include<bitset>
#include<queue>
#include<deque>
#include<stack>
#include<cmath>
#include<list>
#include<map>
#include<set>
//#define DEBUG
#define RI register int
using namespace std;
typedef long long ll;
//typedef __int128 lll;
const int N=10+10;
const int MOD=1e9+7;
const double PI = acos(-1.0);
const double EXP = 1E-8;
const int INF = 0x3f3f3f3f;
int n,m,k,q,ans;
const int maxn=12;
struct Matrix
{
    int a[maxn][maxn];
    void in(){for(int i=0;i<n;i++)for(int j=0;j<n;j++)scanf(" %c",a[i]+j);}
    Matrix rotate()
    {
        Matrix ans;
        for(int i=0;i<n;i++)for(int j=0;j<n;j++)ans.a[i][j]=a[n-j-1][i];
        return ans;
    }
    Matrix reflex()
    {
        Matrix ans;
        for(int i=0;i<n;i++)for(int j=0;j<n;j++)ans.a[i][j]=a[i][n-j-1];
        return ans;
    }
    bool operator==(Matrix b)//判断两个矩阵是否相等
    {
        for(int i=0;i<n;i++)for(int j=0;j<n;j++)
        if(a[i][j]!=b.a[i][j])return false;
        return true;
    }
}from,to,mid;
int main()
{
#ifdef DEBUG
	freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
#endif
    scanf("%d",&n);
    from.in();to.in();
    mid=from;
    for(int i=1;i<=3;i++)
    {
        mid=mid.rotate();
        if(mid==to){printf("%d\n",i);return 0;}
    }
    mid=from.reflex();
    if(mid==to){printf("4\n");return 0;}
    for(int i=1;i<=3;i++)
    {
        mid=mid.rotate();
        if(mid==to){printf("5\n");return 0;}
    }
    if(from==to){printf("6\n");return 0;}
    printf("7\n");//这些数字的顺序很重要
    //cout << "Hello world!" << endl;
    return 0;
}