题解:AT_abc399_c [ABC399C] Make it Forest

· · 题解

思路

对于 k 个顶点的树,有 k−1 条边。对于有 p 个连通分量的图来说,边数就应为 n−p。因此,需要删除的边数为 m−n+p

code