TopCoder

User's AC Ratio

75.0% (3/4)

Submission's AC Ratio

50.0% (5/10)

Tags

Description

Given a bipartite graph with $L + R$ vertices and $M$ edges. $i$-th edge is $(a_ i, b_ i)$.

Calculate the maximum matching.

Input Format

$L$ $R$ $M$
$a_ 0$ $b_ 0$
$a_ 1$ $b_ 1$
:
$a_ {M - 1}$ $b_ {M - 1}$

Output Format

$K$
$c_ 0$ $d_ 0$
$c_ 1$ $d_ 1$
:
$c_ {K - 1}$ $d_ {K - 1}$

$K$ is the number of maximum matching, and $(c_ i, d_ i)$ is the edge of the matching.

Sample Input 1

4 4 7
1 1
2 2
0 0
3 1
1 2
2 0
3 2

Sample Output 1

3
0 0
1 1
2 2

Hints

  • $1 \leq L, R \leq 100,000$
  • $1 \leq M \leq 200,000$
  • $0 \leq a_ i < L$
  • $0 \leq b_ i < R$
  • There is no multiple edges.

Note that timelimit is different from https://judge.yosupo.jp/problem/bipartitematching

Subtasks

No. Testdata Range Score

Testdata and Limits

No. Time Limit (ms) Memory Limit (VSS, KiB) Output Limit (KiB) Subtasks
0 2000 2097152 2097152
1 2000 2097152 2097152
2 2000 2097152 2097152
3 2000 2097152 2097152
4 2000 2097152 2097152
5 2000 2097152 2097152
6 2000 2097152 2097152
7 2000 2097152 2097152
8 2000 2097152 2097152
9 2000 2097152 2097152
10 2000 2097152 2097152
11 2000 2097152 2097152
12 2000 2097152 2097152
13 2000 2097152 2097152
14 2000 2097152 2097152
15 2000 2097152 2097152
16 2000 2097152 2097152
17 2000 2097152 2097152
18 2000 2097152 2097152
19 2000 2097152 2097152
20 2000 2097152 2097152
21 2000 2097152 2097152
22 2000 2097152 2097152
23 2000 2097152 2097152
24 2000 2097152 2097152
25 2000 2097152 2097152
26 2000 2097152 2097152
27 2000 2097152 2097152
28 2000 2097152 2097152
29 2000 2097152 2097152
30 2000 2097152 2097152
31 2000 2097152 2097152
32 2000 2097152 2097152
33 2000 2097152 2097152
34 2000 2097152 2097152
35 2000 2097152 2097152