又做了一道,代码写的真心丑,自己都看不下去了..................
code
/* ID : Your ID LANG : C++ PROB : transform */ #include <set> #include <map> #include <ctime> #include <queue> #include <cmath> #include <stack> #include <limits> #include <vector> #include <bitset> #include <string> #include <cstdio> #include <cstring> #include <fstream> #include <string.h> #include <iostream> #include <algorithm> #define Si set<int> #define LL long long #define pb push_back #define PS printf(" ") #define Vi vector<int> #define LN printf("\n") #define lson l,m,rt << 1 #define rson m+1,r,rt<<1|1 #define SD(a) scanf("%d",&a) #define PD(a) printf("%d",a) #define SET(a,b) memset(a,b,sizeof(a)) #define FF(i,a) for(int i(0);i<(a);i++) #define FD(i,a) for(int i(a);i>=(1);i--) #define FOR(i,a,b) for(int i(a);i<=(b);i++) #define FOD(i,a,b) for(int i(a);i>=(b);i--) #define readf freopen("input.txt","r",stdin) #define writef freopen("output.txt","w",stdout) const int maxn = 1005; const int INF = 0xfffffff; const int dx[]={0,1,0,-1}; const int dy[]={1,0,-1,0}; const double pi = acos(-1.0); using namespace std; int N; char maze[11][11]; char b[11][11]; bool comp(char a[11][11]){ FOR(i,1,N) FOR(j,1,N){ if(a[i][j]!=b[i][j]) return false; } return true; } bool rotate_90(){ char tmp[11][11]; FOR(i,1,N) FOR(j,1,N){ tmp[j][N-i+1]=maze[i][j]; } if(comp(tmp)) return true; return false; } bool rotate_180(){ char tmp[11][11]; FOR(i,1,N) FOR(j,1,N){ tmp[N-i+1][N-j+1]=maze[i][j]; } if(comp(tmp)) return true; return false; } bool rotate_270(){ char tmp[11][11]; FOR(i,1,N) FOR(j,1,N){ tmp[N-j+1][i]=maze[i][j]; } if(comp(tmp)) return true; return false; } bool reflect(){ char tmp[11][11]; FOR(i,1,N) FOR(j,1,N){ tmp[i][N-j+1]=maze[i][j]; } if(comp(tmp)) return true; return false; } bool comb(){ char tmp1[11][11],tmp2[11][11]; FOR(i,1,N) FOR(j,1,N){ tmp1[i][N-j+1]=maze[i][j]; } FOR(i,1,N) FOR(j,1,N){ tmp2[j][N-i+1]=tmp1[i][j]; } if(comp(tmp2)) return true; FOR(i,1,N) FOR(j,1,N){ tmp2[N-i+1][N-j+1]=tmp1[i][j]; } if(comp(tmp2)) return true; FOR(i,1,N) FOR(j,1,N){ tmp2[N-j+1][i]=tmp1[i][j]; } if(comp(tmp2)) return true; return false; } int main() { freopen("transform.in","r",stdin); freopen("transform.out","w",stdout); SD(N); FOR(i,1,N) FOR(j,1,N){ scanf(" %c",&maze[i][j]); } FOR(i,1,N) FOR(j,1,N) scanf(" %c",&b[i][j]); if(rotate_90()){ puts("1");return 0; } if(rotate_180()){ puts("2");return 0; } if(rotate_270()){ puts("3");return 0; } if(reflect()){ puts("4");return 0; } if(comb()){ puts("5");return 0; } if(comp(maze)){ puts("6");return 0; } puts("7"); return 0; }