QOJ.ac

QOJ

Time Limit: 3 s Memory Limit: 512 MB Total points: 100

#873. 柯尼斯堡七桥问题

Statistics

给定一个图,如果存在一条简单路径经过其所有的桥,我们称该图为 Königsbergsy。其中,桥是指删除后会使图不连通的边。简单路径是指每个顶点最多访问一次的路径。

给定一个图 $G$,我们希望向其中添加一些边,使其成为 Königsbergsy 图。(你可以在同一对顶点之间添加多条边)。确定结果图可以拥有的桥的最大数量。

输入格式

第一行包含两个整数 $n$ 和 $m$ ($2 \le n \le 10^6$; $0 \le m \le 10^6$),分别表示图的顶点数和边数。

接下来的 $m$ 行,每行包含两个整数 $u_i, v_i$ ($0 \le u_i, v_i \le n - 1$),描述连接顶点 $u_i$ 和 $v_i$ 的一条边。

输出格式

输出一个整数,表示结果图可以拥有的桥的最大数量。

样例

样例输入 1

4 3
0 1
1 2
2 0

样例输出 1

1

样例输入 2

4 2
0 1
1 2

样例输出 2

3

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.