Problem 2316 · Medium

Count Unreachable Pairs of Nodes in an Undirected Graph

Join connected nodes with union-find, then count pairs that cross between components.

Open the interactive visualisation