Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define ll long long
- #include <bits/stdc++.h>
- using namespace std;
- const int OO = 1e9;
- const double EPS = 1e-9;
- class pattern {
- public:
- int n;
- char arr[10][10];
- pattern(int n, char arr[10][10]) {
- this->n = n;
- for(int i = 0; i < n; i++) {
- for(int j = 0; j < n; j++) {
- this->arr[i][j] = arr[i][j];
- }
- }
- }
- bool operator == (const pattern &p) const {
- for(int i = 0; i < n; i++) {
- for(int j = 0; j < n; j++) {
- if(arr[i][j] != p.arr[i][j]) {
- return false;
- }
- }
- }
- return true;
- }
- void rotate_90() {
- char new_arr[10][10];
- for(int col = 0; col < n; col++) {
- for(int row = n-1; row >= 0; row--) {
- new_arr[col][n-1-row] = arr[row][col];
- }
- }
- for(int i = 0; i < n; i++) {
- for(int j = 0; j < n; j++) {
- arr[i][j] = new_arr[i][j];
- }
- }
- }
- void reflect() {
- for(int row = 0; 2*row < n; row++) {
- for(int col = 0; col < n; col++) {
- swap(arr[row][col],arr[n-row-1][col]);
- }
- }
- }
- };
- int main()
- {
- ios_base::sync_with_stdio(false);
- cin.tie(NULL);
- cout.tie(NULL);
- int n;
- int ti = 1;
- while(cin >> n) {
- char arr1[10][10];
- char arr2[10][10];
- for(int i = 0; i < n; i++) {
- for(int j = 0; j < n; j++) {
- cin >> arr1[i][j];
- }
- for(int j = 0; j < n; j++) {
- cin >> arr2[i][j];
- }
- }
- pattern p1 = pattern(n,arr1);
- pattern p2 = pattern(n,arr2);
- if(p1 == p2) {
- cout << "Pattern " << ti++ << " was preserved.\n";
- continue;
- }
- for(int i = 90; i < 360; i += 90) {
- p1.rotate_90();
- if(p1 == p2) {
- cout << "Pattern " << ti++ << " was rotated " << i << " degrees.\n";
- break;
- }
- }
- if(p1 == p2) {
- continue;
- }
- p1.rotate_90();
- p1.reflect();
- if(p1 == p2) {
- cout << "Pattern " << ti++ << " was reflected vertically.\n";
- continue;
- }
- for(int i = 90; i < 360; i += 90) {
- p1.rotate_90();
- if(p1 == p2) {
- cout << "Pattern " << ti++ << " was reflected vertically and rotated " << i << " degrees.\n";
- break;
- }
- }
- if(p1 == p2) {
- continue;
- }
- cout << "Pattern " << ti++ << " was improperly transformed.\n";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement