# competitive-verifier: PROBLEM https://onlinejudge.u-aizu.ac.jp/courses/library/3/DSL/all/DSL_1_A
import sys
input = sys.stdin.buffer.readline
from examples.python.union_find import UnionFind
def main() -> None:
N, Q = map(int, input().split())
uf = UnionFind(N)
for _ in range(Q):
t, u, v = map(int, input().split())
if t == 0:
uf.unite(u, v)
else:
print(int(uf.is_same(u, v)))
if __name__ == "__main__":
main()
| Env | Name | Status | Elapsed | Memory |
|---|---|---|---|---|
| Python | 00_small_00 |
|
18 ms | 10 MB |
| Python | 00_small_01 |
|
18 ms | 10 MB |
| Python | 01_rand_00 |
|
18 ms | 10 MB |
| Python | 01_rand_01 |
|
18 ms | 10 MB |
| Python | 01_rand_02 |
|
18 ms | 10 MB |
| Python | 01_rand_03 |
|
18 ms | 10 MB |
| Python | 01_rand_04 |
|
19 ms | 10 MB |
| Python | 01_rand_05 |
|
18 ms | 10 MB |
| Python | 02_linear_00 |
|
18 ms | 10 MB |
| Python | 02_linear_01 |
|
20 ms | 10 MB |
| Python | 02_linear_02 |
|
28 ms | 11 MB |
| Python | 02_linear_03 |
|
39 ms | 11 MB |
| Python | 03_grid_00 |
|
18 ms | 10 MB |
| Python | 03_grid_01 |
|
18 ms | 10 MB |
| Python | 03_grid_02 |
|
18 ms | 10 MB |
| Python | 03_grid_03 |
|
18 ms | 10 MB |
| Python | 03_grid_04 |
|
18 ms | 10 MB |
| Python | 03_grid_05 |
|
18 ms | 10 MB |
| Python | 03_grid_06 |
|
18 ms | 11 MB |
| Python | 03_grid_07 |
|
19 ms | 11 MB |
| Python | 03_grid_08 |
|
19 ms | 11 MB |
| Python | 04_critical_00 |
|
39 ms | 11 MB |
| Python | 04_critical_01 |
|
39 ms | 11 MB |
| Python | 05_groups_00 |
|
66 ms | 11 MB |
| Python | 05_groups_01 |
|
67 ms | 11 MB |
| Python | 05_groups_02 |
|
68 ms | 11 MB |
| Python | 05_groups_03 |
|
65 ms | 11 MB |
| Python | 05_groups_04 |
|
65 ms | 11 MB |
| Python | 06_randmax_00 |
|
20 ms | 11 MB |
| Python | 06_randmax_01 |
|
74 ms | 11 MB |
| Python | 06_randmax_02 |
|
95 ms | 11 MB |
| Python | 06_randmax_03 |
|
128 ms | 11 MB |