QOJ.ac

QOJ

Límite de tiempo: 4 s Límite de memoria: 512 MB Puntuación total: 100

#1454. Um_nik 的算法

Estadísticas

你能复刻我的学士论文吗?

我给你一个无向二分图。设 $K$ 为其最大匹配的大小。请设计一个算法,找到一个大小至少为 $0.95 \cdot K$ 的匹配。

如果你想通过此题,我建议你尽可能优化你的代码。

输入格式

第一行包含三个正整数 $n_1, n_2$ 和 $m$ ($1 \le n_1, n_2, m \le 2 \cdot 10^6$),分别表示第一部分的顶点数、第二部分的顶点数以及图中的边数。

接下来 $m$ 行描述边,每行一条。每条边的描述包含两个整数 $u$ 和 $v$ ($1 \le u \le n_1, 1 \le v \le n_2$),表示连接第一部分中顶点 $u$ 和第二部分中顶点 $v$ 的边的编号。图中不存在连接相同顶点的多条边。

输出格式

第一行输出一个整数 $L$,表示你找到的匹配的大小。必须满足不等式 $0.95 \cdot K \le L$。

在接下来的 $L$ 行中,输出你匹配中边的编号。边的编号按照输入中给出的顺序从 $1$ 到 $m$ 进行编号。

样例

样例输入 1

3 2 4
1 1
2 1
3 1
3 2

样例输出 1

2
1
4

样例输入 2

20 20 20
1 1
2 2
3 3
4 4
5 5
6 6
7 7
8 8
9 9
10 10
11 11
12 12
13 13
14 14
15 15
16 16
17 17
18 18
19 19
20 20

样例输出 2

19
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19

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.