Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <set>
- #include <string>
- using namespace std;
- int main() {
- int m, n, k,cnt=0;
- cin >> m >> n >> k;
- vector <set <int>> a;
- set <int> b;
- for (int x = 0; x<n; x++) a.push_back(b);
- for (int i =0; i<k; i++) {
- string s;
- cin >> s;
- int d,e;
- if (s=="ADD") {
- cin >> d >> e;
- a[e-1].insert(d);
- } else if (s=="LISTSET") {
- cin >> d;
- if (a[d-1].size()==0) cout << -1 << " ";
- else {
- for( auto c : a[d-1]) cout << c << ' ';
- }
- } else if (s=="LISTSETSOF") {
- cin >> d;
- cnt=0;
- for ( int j = 0; j<a.size(); j++) {
- if (a[j].find(d)!=a[j].end()) {
- cout << j+1 << " "; cnt++;
- }
- } if (cnt==0) cout << -1 << " ";
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement