Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- ID: mickyta1
- TASK: transform
- LANG: C++
- */
- #include <bits/stdc++.h>
- using namespace std;
- typedef vector<char> vc;
- typedef vector<vc> vvc;
- int n;
- vvc rotate90(vvc &a){
- vvc tp(n + 1, vc(n + 1, '\0'));
- for(int i = 1; i <= n; ++i){
- for(int j = 1; j <= n; ++j){
- tp[i][j] = a[n - j + 1][i];
- }
- }
- return tp;
- }
- vvc flipVert(vvc &a){
- vvc tp(n + 1, vc(n + 1, '\0'));
- for(int i = 1; i <= n; ++i){
- for(int j = 1; j <= n; ++j){
- tp[i][j] = a[i][n - j + 1];
- }
- }
- return tp;
- }
- int main(){
- freopen("transform.in", "r", stdin);
- freopen("transform.out", "w", stdout);
- scanf("%d", &n);
- vvc st(n + 1, vc(n + 1, '\0'));
- vvc tp(n + 1, vc(n + 1, '\0'));
- for(int i = 1; i <= n; ++i){
- for(int j = 1; j <= n; ++j){
- scanf(" %c", &st[i][j]);
- tp[i][j] = st[i][j];
- }
- }
- vvc tr(n + 1, vc(n + 1, '\0'));
- for(int i = 1; i <= n; ++i){
- for(int j = 1; j <= n; ++j){
- scanf(" %c", &tr[i][j]);
- }
- }
- for(int i = 1; i <= 3; ++i){
- tp = rotate90(tp);
- if(tp == tr){
- cout << i << '\n';
- return 0;
- }
- }
- tp = rotate90(tp);
- tp = flipVert(tp);
- if(tp == tr){
- cout << "4\n";
- return 0;
- }
- for(int i = 1; i <= 3; ++i){
- tp = rotate90(tp);
- if(tp == tr){
- cout << "5\n";
- return 0;
- }
- }
- if(st == tr){
- cout << "6\n";
- return 0;
- }
- cout << "7\n";
- fclose(stdin);
- fclose(stdout);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement