QOJ.ac

QOJ

Type: Editorial

Status: Open

Posted by: jiangly

Posted at: 2025-12-14 07:15:08

Last updated: 2025-12-14 07:15:11

Back to Problem

题解

把过程倒过来,相当于从所有边全黑开始,每次选一个邻边全黑的点,将它的一条邻边染白,使得最后黑色边最少。容易发现一个大小为 $x$ 的连通块可以染白 $x-1$ 条边,因此答案为 $m-$ 连通块数。时间复杂度 $O(n+m)$。

Comments

No comments yet.