Graph Theory37 sections · 1633 units
Open in Course

CSES 1676 Road Construction - Problem Statement

CSES Problem Set

Problem: Road Construction (CSES) Task: You have nn cities and 00 roads. You add mm roads one by one. After each road, report: number of components and size of the largest component.

This is direct DSU application. Track component count (decrement on successful union) and max size (update after union). Output both after each edge. Use union by size so you can track component sizes directly in the DSU array. This problem tests your ability to maintain extra information alongside the DSU structure.