Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<vector>
- #include<algorithm>
- #include<string>
- #include<set>
- #include<functional>
- using ll= unsigned long long;
- using namespace std;
- int main() {
- ios::sync_with_stdio(0);
- cin.tie(0);
- int n, m, k, a, b;
- string s;
- vector<set<int>>e(100);
- cin >> m >> n;
- cin >> k;
- vector<set<int>>v;
- vector<vector<int>>vy;
- v.resize(n);
- vy.reserve(1000);
- for (int i = 0; i < k; ++i) {
- cin >> s;
- if (s == "ADD") {
- cin >> a >> b;
- e[a - 1].insert(b);
- v[b - 1].insert(a);
- }
- if (s == "LISTSETSOF") {
- vy.push_back({});
- cin >> a;
- if (e[a-1].size() == 0)vy[vy.size() - 1].push_back(-1);
- else for (int j : e[a-1])vy[vy.size() - 1].push_back(j);
- }
- if (s == "LISTSET") {
- vy.push_back({});
- cin >> a;
- if (v[a - 1].size() == 0)vy[vy.size() - 1].push_back(-1);
- else for (int j : v[a-1])vy[vy.size() - 1].push_back(j);
- }
- }
- for (auto r : vy) {
- for (int y : r)cout << y << ' ';
- cout << '\n';
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment