Graph Theory37 sections · 1633 units
Open in Course

USACO 644 Closing the Farm - Problem Statement

USACO Gold

Problem: Closing the Farm (USACO Gold)

Link: USACO 644

Task: Barns close one by one. Before each closing, is the remaining farm connected?

Process in reverse: start with no barns, add them in reverse closing order. Check connectivity after each addition. This is incremental, perfect for DSU. When you add a barn, union it with all its already-open neighbors. Track the component count to determine if the farm is connected.