Guest User

Untitled

a guest
Mar 13th, 2019
3,319
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <algorithm>
  4. using namespace std;
  5. #define int long long
  6. const int MAXN = 500;
  7. int a[MAXN][MAXN];
  8. int b[MAXN][MAXN];
  9. vector<int> aa[MAXN * 2];
  10. vector<int> bb[MAXN * 2];
  11. signed main() {
  12. ios_base::sync_with_stdio(false);
  13.  
  14. int n, m;
  15. cin >> n >> m;
  16. for (int i = 0; i < n; ++i)
  17. for (int j = 0; j < m; ++j) {
  18. cin >> a[i][j];
  19. aa[i + j].push_back(a[i][j]);
  20. }
  21. for (int i = 0; i < n; ++i)
  22. for (int j = 0; j < m; ++j) {
  23. cin >> b[i][j];
  24. bb[i + j].push_back(b[i][j]);
  25. }
  26. bool ok = 1;
  27. for (int i = 0; i < MAXN * 2; ++i) {
  28. sort(aa[i].begin(), aa[i].end());
  29. sort(bb[i].begin(), bb[i].end());
  30. if (aa[i] != bb[i])
  31. ok = 0;
  32. }
  33. if (ok)
  34. cout << "YES";
  35. else
  36. cout << "NO";
  37. return 0;
  38. }
Add Comment
Please, Sign In to add comment