library

This documentation is automatically generated by competitive-verifier/competitive-verifier

View the Project on GitHub hidehic0/library

:heavy_check_mark: tests/unionfind.py

Depends on

Code

# 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

Test cases

Env Name Status Elapsed Memory
Python example_00 :heavy_check_mark: AC 33 ms 12 MB
Python max_random_00 :heavy_check_mark: AC 915 ms 28 MB
Python max_random_01 :heavy_check_mark: AC 941 ms 28 MB
Python max_random_02 :heavy_check_mark: AC 927 ms 25 MB
Python path_00 :heavy_check_mark: AC 742 ms 35 MB
Python path_01 :heavy_check_mark: AC 740 ms 40 MB
Python path_02 :heavy_check_mark: AC 629 ms 46 MB
Python path_03 :heavy_check_mark: AC 615 ms 46 MB
Python random_00 :heavy_check_mark: AC 835 ms 24 MB
Python random_01 :heavy_check_mark: AC 803 ms 24 MB
Python random_02 :heavy_check_mark: AC 612 ms 21 MB
Python random_03 :heavy_check_mark: AC 179 ms 15 MB
Python random_04 :heavy_check_mark: AC 506 ms 18 MB
Python random_05 :heavy_check_mark: AC 633 ms 22 MB
Python random_06 :heavy_check_mark: AC 504 ms 22 MB
Python random_07 :heavy_check_mark: AC 101 ms 13 MB
Python random_08 :heavy_check_mark: AC 255 ms 15 MB
Python random_09 :heavy_check_mark: AC 1047 ms 27 MB
Back to top page