library

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

View the Project on GitHub hidehic0/library

:warning: libs/coordinates_to_id.py

Code

from typing import List, Tuple


def coordinates_to_id(H: int, W: int) -> Tuple[List[List[int]], List[Tuple[int]]]:
    """
    座標にID変換します

    返り値は、
    最初のが、座標からid
    二つめのが、idから座標
    です
    """
    ItC = [[-1] * W for _ in [0] * H]
    CtI = [(-1, -1) for _ in [0] * (H * W)]

    i = 0

    for x in range(H):
        for y in range(W):
            ItC[x][y] = i
            CtI[i] = (x, y)
            i += 1

    return CtI, ItC
Back to top page