#2和#7WA了
查看原帖
#2和#7WA了
756220
diaq楼主2023/1/14 15:00
#include<bits/stdc++.h>
using namespace std;
int n;
char x[12][12],y[12][12],z[12][12];
bool check1(){
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			z[j][n-i+1]=x[i][j];
		}
	}
	for(int i=1;i<n;i++){
		for(int j=1;j<=n;j++){
			if(z[i][j]!=y[i][j])return false;
		}
	}
	return true;
}
bool check2(){
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			z[n-i+1][n-j+1]=x[i][j];
		}
	}
	for(int i=1;i<n;i++){
		for(int j=1;j<=n;j++){
			if(z[i][j]!=y[i][j])return false;
		}
	}
	return true;
}
bool check3(){
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			z[n-j+1][i]=x[i][j];
		}
	}
	for(int i=1;i<n;i++){
		for(int j=1;j<=n;j++){
			if(z[i][j]!=y[i][j])return false;
		}
	}
	return true;
}
bool check4(){
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			z[i][n-j+1]=x[i][j];
		}
	}
	for(int i=1;i<n;i++){
		for(int j=1;j<=n;j++){
			if(z[i][j]!=y[i][j])return false;
		}
	}
	return true;
}
bool check5(){
	check4();
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			x[i][j]=z[i][j];  
			if(check1())return true;
		}
	}
    for(int i=1;i<=n;i++){ 
		for(int j=1;j<=n;j++){ 
			x[i][j]=z[i][j]; 
			if(check2())return true;
		}
    }
    for(int i=1;i<=n;i++){ 
		for(int j=1;j<=n;j++){ 
			x[i][j]=z[i][j]; 
			if(check3())return true;
		}
    }
    return false;
}
bool check6(){
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			if(z[i][j]!=y[i][j])return false;
		}
	}
	return true;
}
void check(){
	if(check1()){cout<<1;return;}
	if(check2()){cout<<2;return;}
	if(check3()){cout<<3;return;}
	if(check4()){cout<<4;return;}
	if(check5()){cout<<5;return;}
	if(check6()){cout<<6;return;}
	cout<<7;
	return;
}
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			cin>>x[i][j];
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			cin>>y[i][j];
		}
	}
	check();

	return 0;
}

2023/1/14 15:00
加载中...