Professional Documents
Culture Documents
Restructed
Restructed
h>
using namespace std;
int n, q, d[200005];
void make_set () {
if (u == d[u])
return u;
return d[u] = find_set (d[u]);
}
u = find_set (u);
v = find_set (v);
if (u == v)
return;
d[u] = v;
}
int main () {
ios_base::sync_with_stdio (false);
cin.tie (0);
cout.tie (0);
freopen ("restruct.inp", "r", stdin);
freopen ("restruct.out", "w", stdout);
while (q--) {
int ktv, x, y;
cin >> ktv >> x >> y;
if (ktv == 1) {
union_set (x, y);
}
else {
if (ktv == 2) {
for (int i = x; i <= y; i++) {
union_set (i, x);
union_set (i, y);
}
}
else {
if (find_set (x) == find_set (y))
cout << "YES\n";
else
cout << "NO\n";
}
}
return 0;
}
// bài này là restruct, bài này cũng chưa chấm nhá