# 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.in |
![]() |
23 ms | 11 MB |
Python | 00_small_01.in |
![]() |
22 ms | 10 MB |
Python | 01_rand_00.in |
![]() |
22 ms | 10 MB |
Python | 01_rand_01.in |
![]() |
22 ms | 10 MB |
Python | 01_rand_02.in |
![]() |
21 ms | 10 MB |
Python | 01_rand_03.in |
![]() |
22 ms | 10 MB |
Python | 01_rand_04.in |
![]() |
22 ms | 10 MB |
Python | 01_rand_05.in |
![]() |
22 ms | 10 MB |
Python | 02_linear_00.in |
![]() |
22 ms | 10 MB |
Python | 02_linear_01.in |
![]() |
24 ms | 10 MB |
Python | 02_linear_02.in |
![]() |
31 ms | 11 MB |
Python | 02_linear_03.in |
![]() |
41 ms | 11 MB |
Python | 03_grid_00.in |
![]() |
21 ms | 10 MB |
Python | 03_grid_01.in |
![]() |
21 ms | 10 MB |
Python | 03_grid_02.in |
![]() |
21 ms | 10 MB |
Python | 03_grid_03.in |
![]() |
21 ms | 10 MB |
Python | 03_grid_04.in |
![]() |
21 ms | 10 MB |
Python | 03_grid_05.in |
![]() |
21 ms | 10 MB |
Python | 03_grid_06.in |
![]() |
21 ms | 11 MB |
Python | 03_grid_07.in |
![]() |
21 ms | 11 MB |
Python | 03_grid_08.in |
![]() |
22 ms | 11 MB |
Python | 04_critical_00.in |
![]() |
41 ms | 11 MB |
Python | 04_critical_01.in |
![]() |
42 ms | 11 MB |
Python | 05_groups_00.in |
![]() |
68 ms | 11 MB |
Python | 05_groups_01.in |
![]() |
69 ms | 11 MB |
Python | 05_groups_02.in |
![]() |
68 ms | 11 MB |
Python | 05_groups_03.in |
![]() |
67 ms | 11 MB |
Python | 05_groups_04.in |
![]() |
68 ms | 11 MB |
Python | 06_randmax_00.in |
![]() |
24 ms | 11 MB |
Python | 06_randmax_01.in |
![]() |
77 ms | 11 MB |
Python | 06_randmax_02.in |
![]() |
98 ms | 11 MB |
Python | 06_randmax_03.in |
![]() |
129 ms | 11 MB |