【悬赏3关注】蒟蒻求助此题,调了1h WA57pts
查看原帖
【悬赏3关注】蒟蒻求助此题,调了1h WA57pts
638141
Literally楼主2023/8/4 08:51
#include <bits/stdc++.h>
using namespace std;
char juzhen[15][15];
char temp[15][15];
char final[15][15];
int n;
void debug(){
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			cout<<juzhen[i][j]<<" ";
		}
		cout<<endl;
	}
	cout<<endl;
	return;
}
void copy(){
	memset(temp,0,sizeof(temp));
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			temp[i][j]=juzhen[i][j];
		}
	}
}
bool check(){
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			if(final[i][j]!=juzhen[i][j]){
				return 0;
			}
		}
	}
	return 1;
}
void rotate90(){
	//memset(juzhen,0,sizeof(juzhen));
	copy();
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			juzhen[j][n-i+1]=temp[i][j];
		}
	}
	copy();
}
void rotate180(){
	rotate90();
	rotate90();
}
void rotate270(){
	rotate90();
	rotate90();
	rotate90();
}
void shuiping(){
	//memset(juzhen,0,sizeof(juzhen));
	for(int i=1;i<=n/2;i++){
		for(int j=1;j<=n;j++){
			swap(juzhen[i][j],juzhen[n+1-i][j]);
		}
	}
	
} 
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			cin>>juzhen[i][j];
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			cin>>final[i][j];
		}
	}
	if(check()){
		cout<<6;
		return 0;
	}
	//debug();
	rotate90();
	if(check()){
		cout<<1;
		return 0;
	}
	//debug();
	rotate180();
	if(check()){
		cout<<2;
		return 0;
	}
	//debug();
	rotate270();
	if(check()){
		cout<<3;
		return 0;
	}
	//debug();
	shuiping();
	if(check()){
		cout<<4;
		return 0;
	}
	shuiping();
	rotate90();
	if(check()){
		cout<<5;
		return 0;
	}
	shuiping();
	rotate180();
	if(check()){
		cout<<5;
		return 0;
	}
	shuiping();
	rotate270();
	if(check()){
		cout<<5;
		return 0;
	}
	//debug();
	cout<<7; 
	return 0; 
}
2023/8/4 08:51
加载中...