QOJ.ac

QOJ

Límite de tiempo: 1.0 s Límite de memoria: 256 MB Puntuación total: 100 Hackeable ✓

#12216. 自由边

Estadísticas

你有一个无向图。最初,所有边都是白色的。你可以选择一些边并将它们涂成黑色。 在此之后,只要存在一个顶点,使得恰好有一条白色边与它相连,这条白色边也会变成黑色。 你的目标是选择最少数量的边涂成黑色,使得在过程结束后,所有的边都变成黑色。

输入格式

第一行包含两个整数 $n$ 和 $m$:图的顶点数和边数($1 \le n, m \le 10^5$)。 接下来的 $m$ 行包含图的边描述。每一行包含两个整数 $a_i$ 和 $b_i$,描述连接顶点 $a_i$ 和 $b_i$ 的一条边($1 \le a_i, b_i \le n, a_i \neq b_i$)。 保证图中没有重边。

输出格式

输出一个整数:为了使过程结束后所有边都变为黑色,你需要涂成黑色的最少边数。

样例

样例输入 1

5 3
3 5
5 1
1 3

样例输出 1

1

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
#351EditorialOpen题解jiangly2025-12-14 07:15:11View

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.