TopCoder

User's AC Ratio

NaN% (0/0)

Submission's AC Ratio

NaN% (0/0)

Tags

Description

Given a simple undirected graph with $N$ vertices and $M$ edges. $i$-th edge is $(u_ i, v_ i)$.

Calculate the maximum matching.

Input Format

$N$ $M$
$u_ 0$ $v_ 0$
$u_ 1$ $v_ 1$
:
$u_ {M - 1}$ $v_ {M - 1}$

Output Format

$X$
$a_ 0$ $b_ 0$
$a_ 1$ $b_ 1$
:
$a_ {X - 1}$ $b_ {X - 1}$

$X$ is the size of the maximum matching.

Sample Input 1

7 8
2 0
0 5
5 6
6 1
1 0
1 3
3 4
1 4

Sample Output 1

3
0 2
1 6
3 4

Sample Input 2

5 4
0 1
0 2
0 3
0 4

Sample Output 2

1
0 1

Hints

  • $1 \leq N \leq 500$
  • $0 \leq M \leq \frac{N(N-1)}{2}$
  • $0 \leq u_ i, v_ i < N$

Subtasks

No. Testdata Range Score

Testdata and Limits

No. Time Limit (ms) Memory Limit (VSS, KiB) Output Limit (KiB) Subtasks
0 5000 2097152 2097152
1 5000 2097152 2097152
2 5000 2097152 2097152
3 5000 2097152 2097152
4 5000 2097152 2097152
5 5000 2097152 2097152
6 5000 2097152 2097152
7 5000 2097152 2097152
8 5000 2097152 2097152
9 5000 2097152 2097152
10 5000 2097152 2097152
11 5000 2097152 2097152