This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def ceil_div(n, d): return -(n // -d) | |
def floor_div(n, d): return n // d |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
from typing import Any, Dict, Iterable, Tuple | |
class UnionFind: | |
def __init__(self, vs: Iterable[Any] = (), es: Iterable[Tuple[Any, Any]] = ()) -> None: | |
self.parent: Dict[Any, Any] = {} | |
self.size: Dict[Any, int] = {} | |
for v in vs: |