-
Notifications
You must be signed in to change notification settings - Fork 0
/
洛谷P1205 [USACO1.2] 方块转换 Transformations.cpp
102 lines (100 loc) · 2.07 KB
/
洛谷P1205 [USACO1.2] 方块转换 Transformations.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
//P1205 [USACO1.2] 方块转换 Transformations
//https://www.luogu.com.cn/problem/P1205
//https://www.luogu.com.cn/record/87542216
//https://www.luogu.com.cn/record/87542740
#include<iostream>
using namespace std;
int n;
char a[11][11],b[11][11],c[11][11];
bool check(int stage,bool check_not_in_stage_5th){
for(int i=1;i<=n;i++){
for(int o=1;o<=n;o++){
if(b[i][o]!=c[i][o]){
return 0;
}
}
}
/*
if(check_not_in_stage_5th){
cout<<stage<<endl;
}else cout<<5<<endl;
*/
check_not_in_stage_5th ? cout<<stage<<endl : cout<<5<<endl;
return 1;
}
void acr(){
for(int i=1;i<=n;i++){
for(int o=1;o<=n;o++){
c[i][o]=a[i][o];
}
}
return;
}
bool check_1to3(bool stage_in_5th){
for(int i=1;i<=3;i++){
char tmp[11][11];
for(int y=1;y<=n;y++){
for(int x=1;x<=n;x++){
tmp[x][n-y+1]=c[y][x];
}
}
for(int o=1;o<=n;o++){
for(int p=1;p<=n;p++){
c[o][p]=tmp[o][p];
}
}
if(stage_in_5th){
if(check(i,0)){
return 1;
}
}else if(check(i,1)){
return 1;
}
}
return 0;
}
bool check_4to5(){
char tmp[11][11];
for(int y=1;y<=n;y++){
for(int x=1;x<=n;x++){
tmp[y][x]=c[y][n-x+1];
}
}
for(int o=1;o<=n;o++){
for(int p=1;p<=n;p++){
c[o][p]=tmp[o][p];
}
}
if(check(4,1)){
return 1;
}else{
if(check_1to3(1)){
return 1;
}
}
return 0;
}
int main(){
cin>>n;
for(int i=1;i<=n;i++){
for(int o=1;o<=n;o++){
cin>>a[i][o];
c[i][o]=a[i][o];
}
}
for(int i=1;i<=n;i++){
for(int o=1;o<=n;o++){
cin>>b[i][o];
}
}
if(check_1to3(0)==0){
acr();
if(check_4to5()==0){
acr();
if(check(6,1)==0){
cout<<7<<endl;
}
}
}
return 0;
}