Official Analysis (C++)

We can use a sorted set in place of the linked list mentioned in the official solution.

Implementation

Time Complexity: O(NlogN+BlogB)\mathcal{O}(N \log N + B \log B)

from typing import NamedTuple
class Boot(NamedTuple):
max_depth: int
max_steps: int
index: int
class Tile:

Join the USACO Forum!

Stuck on a problem, or don't understand a module? Join the USACO Forum and get help from other competitive programmers!