-
Notifications
You must be signed in to change notification settings - Fork 0
/
00466.cpp
98 lines (72 loc) · 2.14 KB
/
00466.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
#include <bits/stdc++.h>
using namespace std;
#define ll long long
string a[20], b[20];
bool vref(ll n){
bool same = true;
string cp[n];
for(ll i = 0; i < n; i++){
cp[i] = a[i];
}
for(ll i = n-1, j = 0; i >= 0; i--, j++){
a[j] = cp[i];
if(a[j] != b[j]) same = false;
}
return same;
}
bool check90(ll n){
for(ll i = n-1, k = 0; i >= 0; i--, k++){
string hi;
for(ll j = 0; j < n; j++){
hi += string(1, b[j][i]);
}
if(hi != a[k]) return false;
}
return true;
}
bool check180(ll n){
for(ll i = n-1, k = 0; i >= 0; i--, k++){
string hi = a[i];
reverse(hi.begin(), hi.end());
if(hi != b[k]) return false;
}
return true;
}
bool check270(ll n){
for(ll i = n-1, k = 0; i >= 0; i--, k++){
string hi;
for(ll j = 0; j < n; j++){
hi += string(1, a[j][i]);
}
if(hi != b[k]) return false;
}
return true;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
ll n; ll cs = 0;
while(cin >> n){
cout << "Pattern " << ++cs << " was";
cin.ignore(1000, '\n');
bool same = true;
for(ll i = 0; i < n; i++){
string str; getline(cin, str);
a[i] = str.substr(0, n);
b[i] = str.substr(n+1);
if(a[i]!=b[i]) same = false;
}
if(same) cout << " preserved.\n";
else if(check90(n)) cout << " rotated 90 degrees.\n";
else if(check180(n)) cout << " rotated 180 degrees.\n";
else if(check270(n)) cout << " rotated 270 degrees.\n";
else if(vref(n)) cout << " reflected vertically.\n";
else if(check90(n)) cout << " reflected vertically and rotated 90 degrees.\n";
else if(check180(n)) cout << " reflected vertically and rotated 180 degrees.\n";
else if(check270(n)) cout << " reflected vertically and rotated 270 degrees.\n";
else cout << " improperly transformed.\n";
}
return 0;
}