Expand description

An obvious BFS day that is more efficiently solved with a linear pass and a modified union-find.

Constants

The input map is 100 elements tall

The input map is 100 elements wide

Functions

Naive parsing

Naive solution of finding all points with strictly higher neighbors.

Generate a grid containing an initial basin for each point, then do an efficient union-find to merge the initial basins and yield the actual set of basins in O(grid size) time.

Type Definitions

The map is a grid of WIDTH x HEIGHT containing numbers in [0,9].