#P6113. 【模板】一般图最大匹配
【模板】一般图最大匹配
Description
Given an undirected graph with vertices and edges, find the maximum matching of this graph.
Input Format
The first line contains two positive integers and , representing the number of vertices and the number of edges in the graph.
The next lines each contain two positive integers and , indicating that there is an undirected edge connecting and .
Output Format
The first line contains one integer, the size of the maximum matching.
The second line contains integers. The -th integer denotes the index of the vertex matched with vertex . If vertex is unmatched, output .
If there are multiple solutions, output any one.
10 10
4 3
3 1
4 7
2 10
2 9
3 10
5 9
4 6
1 10
1 7
4
7 9 10 6 0 4 1 0 2 3
Hint
For of the testdata, .
For of the testdata, and .
This problem has 5 extra test cases.
Hint
To make it easier for you to debug your program, the problem setter provides a very ugly testdata generator here.
Translated by ChatGPT 5
京公网安备 11011102002149号