This documentation is automatically generated by competitive-verifier/competitive-verifier
#define PROBLEM "https://judge.yosupo.jp/problem/unionfind"
#include <bits/stdc++.h>
#include <atcoder/dsu>
using namespace std;
using namespace atcoder;
int main() {
int n, q;
cin >> n >> q;
dsu uf(n);
while (q--) {
int t, u, v;
cin >> t >> u >> v;
if (t) {
cout << uf.same(u, v) << '\n';
} else {
uf.merge(u, v);
}
}
return 0;
}
#line 1 "src/example/example_acl.test.cpp"
#define PROBLEM "https://judge.yosupo.jp/problem/unionfind"
#include <bits/stdc++.h>
#include <atcoder/dsu>
using namespace std;
using namespace atcoder;
int main() {
int n, q;
cin >> n >> q;
dsu uf(n);
while (q--) {
int t, u, v;
cin >> t >> u >> v;
if (t) {
cout << uf.same(u, v) << '\n';
} else {
uf.merge(u, v);
}
}
return 0;
}
| Env | Name | Status | Elapsed | Memory |
|---|---|---|---|---|
| g++ | example_00 |
|
62 ms | 14 MB |
| g++ | max_random_00 |
|
274 ms | 14 MB |
| g++ | max_random_01 |
|
238 ms | 15 MB |
| g++ | max_random_02 |
|
279 ms | 14 MB |
| g++ | path_00 |
|
195 ms | 15 MB |
| g++ | path_01 |
|
226 ms | 15 MB |
| g++ | path_02 |
|
135 ms | 15 MB |
| g++ | path_03 |
|
135 ms | 15 MB |
| g++ | random_00 |
|
183 ms | 14 MB |
| g++ | random_01 |
|
191 ms | 14 MB |
| g++ | random_02 |
|
232 ms | 14 MB |
| g++ | random_03 |
|
41 ms | 15 MB |
| g++ | random_04 |
|
119 ms | 14 MB |
| g++ | random_05 |
|
200 ms | 14 MB |
| g++ | random_06 |
|
262 ms | 15 MB |
| g++ | random_07 |
|
38 ms | 14 MB |
| g++ | random_08 |
|
64 ms | 14 MB |
| g++ | random_09 |
|
250 ms | 14 MB |