This documentation is automatically generated by competitive-verifier/competitive-verifier
# competitive-verifier: PROBLEM https://judge.yosupo.jp/problem/unionfind
from libs.unionfind import UnionFind
from libs.standard_input import *
from libs.yn_func import *
N, Q = il()
UF = UnionFind(N)
while Q:
t, u, v = il()
if t == 0:
UF.unite(u, v)
else:
print(int(UF.same(u, v)))
Q -= 1
Env | Name | Status | Elapsed | Memory |
---|---|---|---|---|
Python | example_00 |
![]() |
32 ms | 12 MB |
Python | max_random_00 |
![]() |
471 ms | 28 MB |
Python | max_random_01 |
![]() |
468 ms | 28 MB |
Python | max_random_02 |
![]() |
484 ms | 25 MB |
Python | path_00 |
![]() |
441 ms | 35 MB |
Python | path_01 |
![]() |
446 ms | 40 MB |
Python | path_02 |
![]() |
451 ms | 46 MB |
Python | path_03 |
![]() |
443 ms | 46 MB |
Python | random_00 |
![]() |
357 ms | 24 MB |
Python | random_01 |
![]() |
353 ms | 25 MB |
Python | random_02 |
![]() |
296 ms | 21 MB |
Python | random_03 |
![]() |
85 ms | 15 MB |
Python | random_04 |
![]() |
253 ms | 18 MB |
Python | random_05 |
![]() |
344 ms | 22 MB |
Python | random_06 |
![]() |
268 ms | 22 MB |
Python | random_07 |
![]() |
54 ms | 13 MB |
Python | random_08 |
![]() |
140 ms | 15 MB |
Python | random_09 |
![]() |
471 ms | 27 MB |