#include <bits/stdc++.h>
#include "books.h"
using namespace std;
#define nl '\n';
using ll = long long;
int main() {
int N, Q; cin >> N >> Q;
vector<int> C(N, 1);
vector<int> ID(N);
vector<set<int>> S(2 * N);
for(int i = 0; i < N; i++) {
ID[i] = i;
S[i] = {i};
}
int X = N;
for(int t = 0; t < (N + Q - 1); t++) {
char c; cin >> c;
if (c == 'S') {
int u, v; cin >> u >> v; --u, --v;
int U = ID[u], V = ID[v];
if (size(S[U]) < size(S[V])) swap(U, V);
for(auto &x : S[U]) {
S[X].insert(x);
C[x]++;
}
for(auto &x : S[V]) {
S[X].insert(x);
C[x]++;
}
cout << "DONE" << nl;
cout << u << " " << v << nl;
for(auto x : S[X]) cout << x << " ";
cout << nl;
ID[u] = ID[v] = X++;
}
if (c == 'Q') {
int u, d; cin >> u >> d; --u, --d;
u = ID[u]; cout << u << " " << d << nl;
cout << (S[u].count(d) ? "yes" : "no") << nl;
}
if (c == 'C') {
int x; cin >> x; --x;
cout << C[x] << nl;
}
}
}
/*
6 9
S 1 2
S 1 3
S 3 4
Q 5 1
S 4 5
S 1 6
Q 5 1
Q 1 5
C 1
C 2
C 3
C 4
C 5
C 6
4 4
S 1 2
S 1 3
S 3 4
Q 2 1
Q 2 2
Q 2 3
Q 2 4
*/
Compilation message
servers.cpp:2:10: fatal error: books.h: No such file or directory
2 | #include "books.h"
| ^~~~~~~~~
compilation terminated.