fork download
  1. #include<bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5.  
  6.  
  7. #define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
  8. #define MOD 1000000007
  9. #define MOD1 998244353
  10. #define INF 1e18
  11. #define nline "\n"
  12. #define pb push_back
  13. #define ppb pop_back
  14. #define mp make_pair
  15. #define ff first
  16. #define ss second
  17. #define PI 3.141592653589793238462
  18. #define set_bits __builtin_popcountll
  19. #define sz(x) ((int)(x).size())
  20. #define all(x) (x).begin(), (x).end()
  21.  
  22. typedef long long ll;
  23. typedef unsigned long long ull;
  24. typedef long double lld;
  25. // typedef tree<pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update > pbds; // find_by_order, order_of_key
  26.  
  27. #ifndef ONLINE_JUDGE
  28. #define debug(x) cerr << #x <<" "; _print(x); cerr << endl;
  29. #else
  30. #define debug(x)
  31. #endif
  32.  
  33. void _print(ll t) {cerr << t;}
  34. void _print(int t) {cerr << t;}
  35. void _print(string t) {cerr << t;}
  36. void _print(char t) {cerr << t;}
  37. void _print(lld t) {cerr << t;}
  38. void _print(double t) {cerr << t;}
  39. void _print(ull t) {cerr << t;}
  40.  
  41. template <class T, class V> void _print(pair <T, V> p);
  42. template <class T> void _print(vector <T> v);
  43. template <class T> void _print(set <T> v);
  44. template <class T, class V> void _print(map <T, V> v);
  45. template <class T> void _print(multiset <T> v);
  46. template <class T, class V> void _print(pair <T, V> p) {cerr << "{"; _print(p.ff); cerr << ","; _print(p.ss); cerr << "}";}
  47. template <class T> void _print(vector <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
  48. template <class T> void _print(set <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
  49. template <class T> void _print(multiset <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
  50. template <class T, class V> void _print(map <T, V> v) {cerr << "[ "; for (auto i : v) {_print(i); cerr << " ";} cerr << "]";}
  51.  
  52. void TestCase();
  53.  
  54. int main()
  55. {
  56. fastio();
  57.  
  58. #ifndef ONLINE_JUDGE
  59. freopen("input.txt", "r", stdin);
  60. freopen("output.txt", "w", stdout);
  61. freopen("Error.txt", "w", stderr);
  62. #endif
  63.  
  64. int T=1;
  65. //cin>>T;
  66. while(T--)
  67. TestCase();
  68.  
  69. return 0;
  70. }
  71.  
  72. void rotatematrix(int n, vector<vector<char>> &a)
  73. {
  74. vector<vector<char>> tmp(n,vector<char> (n));
  75. for(int i=0;i<n;++i)
  76. {
  77. for(int j=0;j<n;++j)
  78. {
  79. tmp[i][j]=a[n-1-j][i];
  80. }
  81. }
  82. a=tmp;
  83. }
  84.  
  85. void TestCase()
  86. {
  87. int n;
  88. cin>>n;
  89. vector<vector<char>> a(n,vector<char> (n));
  90. vector<vector<char>> b(n,vector<char> (n));
  91. vector<pair<int,int>> s;
  92. for(int i=0;i<n;++i)
  93. {
  94. for(int j=0;j<n;++j)
  95. {
  96. char c;
  97. cin>>c;
  98. a[i][j]=c;
  99. if(c=='#')
  100. {
  101. s.pb({i,j});
  102. }
  103. }
  104. }
  105. vector<pair<int,int>> t;
  106. for(int i=0;i<n;++i)
  107. {
  108. for(int j=0;j<n;++j)
  109. {
  110. char c;
  111. cin>>c;
  112. b[i][j]=c;
  113. if(c=='#')
  114. {
  115. t.pb({i,j});
  116. }
  117. }
  118. }
  119. debug(s);
  120. debug(t);
  121. if(sz(s)!=sz(t))
  122. {
  123. cout<<"No\n";
  124. }
  125. else{
  126. for(int z=0;z<4;++z)
  127. {
  128. rotatematrix(n,a);
  129. s.clear();
  130. for(int i=0;i<n;++i)
  131. {
  132. for(int j=0;j<n;++j)
  133. {
  134. if(a[i][j]=='#')
  135. {
  136. s.pb({i,j});
  137. }
  138. }
  139. }
  140. int diff=abs(s[0].first - t[0].first) + abs(s[0].second - t[0].second);
  141. bool stat=true;
  142. for(int w=1;w<sz(s);++w)
  143. {
  144. int diff1=abs(s[w].first - t[w].first) + abs(s[w].second - t[w].second);
  145. if(diff1!=diff)
  146. {
  147. stat=false;
  148. break;
  149. }
  150. }
  151. if(stat)
  152. {
  153. cout<<"Yes\n";
  154. return;
  155. }
  156. }
  157. cout<<"No\n";
  158. }
  159. }
Runtime error #stdin #stdout 0.01s 5512KB
stdin
Standard input is empty
stdout
Standard output is empty