#P2756. 飞行员配对方案问题
飞行员配对方案问题
Description
There are pilots in total, including foreign pilots and British pilots. Foreign pilots are numbered from to , and British pilots are numbered from to . Given the cooperation relations between foreign and British pilots, design an algorithm to find the optimal pairing scheme so that the RAF can dispatch the maximum number of aircraft at once.
Input Format
The first line contains two positive integers separated by a space, representing the number of foreign pilots and the total number of pilots .
From the second line to the second-to-last line, each line contains two integers , meaning foreign pilot can cooperate with British pilot .
The last line is guaranteed to be -1 -1, indicating the end of input.
Output Format
This problem uses a Special Judge.
Output the maximum number of aircraft that can be dispatched, and provide one feasible pairing scheme.
The first line contains an integer, the maximum number of aircraft that can be dispatched at once; denote this integer by .
From line to line , each line contains two integers , indicating that in your scheme, foreign pilot is paired with British pilot . The pairs in these lines must be all distinct.
5 10
1 7
1 8
2 6
2 9
2 10
3 7
3 8
4 7
4 8
5 10
-1 -1
4
1 7
2 9
3 8
5 10
Hint
- 【Constraints and Conventions】
- For of the testdata, it is guaranteed that , .
::anti-ai[The same pairing relation will be given at most once.]
- 【Hint】
- Note that the first line reads first, then .
Translated by ChatGPT 5
京公网安备 11011102002149号