#P7687. [CEOI 2005] Critical Network Lines
[CEOI 2005] Critical Network Lines
Description
A communication network contains several nodes and several undirected communication lines that directly connect these nodes. The given network is connected, that is: for any pair of nodes, there exists a communication path formed by connecting (several) communication lines end to end.
Some nodes provide service of type to all nodes (including themselves), and some nodes provide service of type to all nodes (including themselves). A node may provide both types of services. Every node must be able to access both services.
When a communication line breaks, it may happen that some node cannot access a certain service. (That is, there exist a node and a service type such that there is no node that provides this service type and is connected to that node.) We call any communication line that can cause such a situation a critical communication line.
Your task is to write a program to compute how many critical communication lines there are, and output the two endpoints of each critical communication line.
Input Format
The first line contains four integers . Here, is the number of nodes in the network, is the number of communication lines, is the number of nodes that provide service type , and is the number of nodes that provide service type . The nodes are numbered from to .
The second line contains integers, which are the node indices that provide service type .
The third line contains integers, which are the node indices that provide service type .
The next lines each contain two integers , representing the indices of the two endpoints of a communication line. It is guaranteed that between any two nodes there is at most one communication line.
Output Format
The first line contains an integer , the number of critical communication lines.
The next lines each contain two integers , indicating the two endpoints of a critical communication line.
The order of the critical communication lines can be arbitrary, and the order of the two endpoints for each critical communication line can also be arbitrary.
9 10 3 4
2 4 5
4 9 8 3
1 2
4 1
2 3
4 2
1 5
5 6
6 7
6 8
7 9
8 7
3
3 2
5 6
7 9
Hint
This problem is CEOI2005 D2T2. For the original statement, see: Critical Network Lines.
Thanks to
Translated by ChatGPT 5
京公网安备 11011102002149号