QOJ.ac

QOJ

Time Limit: 7.0 s Memory Limit: 2048 MB Total points: 100 Hackable ✓
統計

给定一张二分图,二分图的左部点编号为 $1 \sim L$,右部点编号为 $1 \sim R$。

有 $M$ 条边,第 $i$ 条边连接连接了左侧第 $a_i$ 个点与右侧第 $b_i$ 个点。

找出该二分图的一个最大匹配。

输入格式

输入的第一行包含三个整数 $L$, $R$, $M$。

接下来 $M$ 行,每行两个整数 $a_i, b_i$,描述一条边。图中可能存在重边。

输出格式

输出的第一行包含一个整数 $k$,表示最大匹配的大小。

接下来 $K$ 行,每行两个整数 $c_i$, $d_i$,表示将左侧第 $c_i$ 个点匹配到右侧第 $d_i$ 个点。

如果有多种合法方案,你可以输出任意一种。

样例数据

样例输入

3 2 3
1 1
2 2
3 2

样例输出

2
1 1
3 2

子任务

对于所有数据,$1 \le L, R \le 2 \cdot 10^5$,$1 \le M \le 6 \cdot 10^5$,$1 \le a_i \le L$,$1 \le b_i \le R$。

Discussions

About Discussions

The discussion section is only for posting: Editorials, 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. Submitting multiple issues may cause your account to be banned.
  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.