L12 - C

public
yeskendir.sultanov Mar 31, 2024 Never 58
Clone
C++ l12c.cpp 48 lines (43 loc) | 1.06 KB
1
#include <bits/stdc++.h>
2
3
using namespace std;
4
5
int main() {
6
int m, n, k;
7
cin >> m >> n >> k;
8
set<int> a[n + 1];
9
set<int> b[m + 1];
10
11
for (int i = 0; i < k; ++i) {
12
string op;
13
cin >> op;
14
if (op == "ADD") {
15
int x, id;
16
cin >> x >> id;
17
a[id].insert(x);
18
b[x].insert(id);
19
} else if (op == "SHOWSET") {
20
int id;
21
cin >> id;
22
bool flag = false;
23
for (int x: a[id]) {
24
cout << x << " ";
25
flag = true;
26
}
27
28
if (!flag) {
29
cout << -1;
30
}
31
32
cout << endl;
33
} else {
34
int x;
35
cin >> x;
36
bool flag = false;
37
for (int id: b[x]) {
38
cout << id << " ";
39
flag = true;
40
}
41
if (!flag) {
42
cout << -1;
43
}
44
cout << endl;
45
}
46
}
47
return 0;
48
}
49
50
51