#P15624. [ICPC 2022 Jakarta R] Contingency Plan
[ICPC 2022 Jakarta R] Contingency Plan
题目描述
You are working as a manager in The ICPC Company. In the company building, there are computers, numbered from to . There are cables, numbered from to , that connect all the computers into a single network. Cable connects computer and .
Through your research, there are levels of disasters, numbered from to , that might happen in the future. In disaster level , all cables such that are damaged. Damaged cables cannot be used for a connection.
As a manager, you want to create a contingency plan. In your contingency plan, there should be backup cables, numbered from to . If an existing cable is damaged, then backup cable will be deployed to connect computer and . If an existing cable is not damaged, then backup cable is not deployed and is not used for a connection.
For each disaster level, the backup cables, together with the undamaged cables, must keep all the computers connected in a single network. Furthermore, for practical reasons, if a cable that connects computers and exists, then there should not be any backup cable that connects computers and in your contingency plan.
Create a contingency plan that satisfies all the requirements, or determine if such a plan is impossible to create. If several contingency plans exist, choose any of them.
输入格式
Input begins with an integer () representing the number of computers. Each of the next lines contains integers () representing cable . All the cables connect all the computers into a single network.
输出格式
If a contingency plan is possible to create, then the output consists of lines, representing your contingency plan that satisfies all the requirements. Each line contains integers () representing backup cable . If several contingency plans exist, output any of them.
If a contingency plan is impossible to create, then output in a single line.
7
1 2
3 7
2 4
2 5
1 3
3 6
3 5
6 7
4 6
2 3
1 7
3 4
3
1 2
2 3
-1
提示
Explanation for the sample input/output #1
The following is an illustration for this sample. The circles represent the computers, while the black line and red dashed lines represent existing cables and backup cables, respectively. Damaged cables are not shown in the illustration.
:::align{center}
:::
Explanation for the sample input/output #2
There should be backup cables in the contingency plan. You can only have backup cable, which will connect computers and . The remaining pairs are already connected by the current cables.