Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int main()
- {
- ios_base::sync_with_stdio(false);
- cin.tie(NULL);
- int T; cin >> T;
- if (T == 1)
- {
- int K1; cin >> K1;
- vector<int> o(K1); for (auto &x : o) cin >> x;
- int K2; cin >> K2;
- vector<int> d(K2); for (auto &x : d) cin >> x;
- cout << (o == d ? "S" : "N") << '\n';
- return 0;
- }
- if (T >= 3)
- {
- vector<int> o;
- for (int i = 1; i <= T; i++)
- {
- int K; cin >> K;
- while (K--)
- {
- int X; cin >> X;
- o.push_back(X);
- }
- }
- vector<int> d;
- for (int i = 1; i <= T; i++)
- {
- int K; cin >> K;
- while (K--)
- {
- int X; cin >> X;
- d.push_back(X);
- }
- }
- sort(o.begin(), o.end()); sort(d.begin(), d.end());
- cout << (o == d ? "S" : "N") << '\n';
- return 0;
- }
- int oK1; cin >> oK1;
- vector<int> o1(oK1); for (auto &x : o1) cin >> x;
- int oK2; cin >> oK2;
- vector<int> o2(oK2); for (auto &x : o2) cin >> x;
- while (!o2.empty() && (o1.empty() || o2.back() >= o1.back())) {o1.push_back(o2.back()); o2.pop_back();}
- while (!o1.empty() && (o2.empty() || o1.back() >= o2.back())) {o2.push_back(o1.back()); o1.pop_back();}
- int dK1; cin >> dK1;
- vector<int> d1(dK1); for (auto &x : d1) cin >> x;
- int dK2; cin >> dK2;
- vector<int> d2(dK2); for (auto &x : d2) cin >> x;
- while (!d2.empty() && (d1.empty() || d2.back() >= d1.back())) {d1.push_back(d2.back()); d2.pop_back();}
- while (!d1.empty() && (d2.empty() || d1.back() >= d2.back())) {d2.push_back(d1.back()); d1.pop_back();}
- cout << (o1 == d1 && o2 == d2 ? "S" : "N") << '\n';
- }
Advertisement
Add Comment
Please, Sign In to add comment