QOJ.ac

QOJ

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

#898. 二分图最大匹配

Statistics

给定一张二分图,二分图的左部点编号为 $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$。

About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.