ThegeekKnight16

Jaimitos Blocks

Aug 29th, 2025
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.83 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6.     ios_base::sync_with_stdio(false);
  7.     cin.tie(NULL);
  8.     int T; cin >> T;
  9.     if (T == 1)
  10.     {
  11.         int K1; cin >> K1;
  12.         vector<int> o(K1); for (auto &x : o) cin >> x;
  13.         int K2; cin >> K2;
  14.         vector<int> d(K2); for (auto &x : d) cin >> x;
  15.         cout << (o == d ? "S" : "N") << '\n';
  16.         return 0;
  17.     }
  18.     if (T >= 3)
  19.     {
  20.         vector<int> o;
  21.         for (int i = 1; i <= T; i++)
  22.         {
  23.             int K; cin >> K;
  24.             while (K--)
  25.             {
  26.                 int X; cin >> X;
  27.                 o.push_back(X);
  28.             }
  29.         }
  30.         vector<int> d;
  31.         for (int i = 1; i <= T; i++)
  32.         {
  33.             int K; cin >> K;
  34.             while (K--)
  35.             {
  36.                 int X; cin >> X;
  37.                 d.push_back(X);
  38.             }
  39.         }
  40.         sort(o.begin(), o.end()); sort(d.begin(), d.end());
  41.         cout << (o == d ? "S" : "N") << '\n';
  42.         return 0;
  43.     }
  44.  
  45.     int oK1; cin >> oK1;
  46.     vector<int> o1(oK1); for (auto &x : o1) cin >> x;
  47.     int oK2; cin >> oK2;
  48.     vector<int> o2(oK2); for (auto &x : o2) cin >> x;
  49.  
  50.     while (!o2.empty() && (o1.empty() || o2.back() >= o1.back())) {o1.push_back(o2.back()); o2.pop_back();}
  51.     while (!o1.empty() && (o2.empty() || o1.back() >= o2.back())) {o2.push_back(o1.back()); o1.pop_back();}
  52.  
  53.  
  54.     int dK1; cin >> dK1;
  55.     vector<int> d1(dK1); for (auto &x : d1) cin >> x;
  56.     int dK2; cin >> dK2;
  57.     vector<int> d2(dK2); for (auto &x : d2) cin >> x;
  58.  
  59.     while (!d2.empty() && (d1.empty() || d2.back() >= d1.back())) {d1.push_back(d2.back()); d2.pop_back();}
  60.     while (!d1.empty() && (d2.empty() || d1.back() >= d2.back())) {d2.push_back(d1.back()); d1.pop_back();}
  61.  
  62.  
  63.     cout << (o1 == d1 && o2 == d2 ? "S" : "N") << '\n';
  64. }
Advertisement
Add Comment
Please, Sign In to add comment