#P1345. [USACO5.4] 奶牛的电信 Telecowmunication
[USACO5.4] 奶牛的电信 Telecowmunication
Description
Farmer John's cows like to keep in touch by email, so they set up a cow computer network to communicate. The machines send email as follows: if there exists a sequence of computers such that is connected to , is connected to , and so on, then computers and can exchange email.
Unfortunately, sometimes a cow may accidentally step on a computer, and Farmer John's truck might run over a computer, and that unlucky computer will break. This means that computer can no longer send email, and all connections incident to it become unusable.
Two cows wonder: if the two of us are to be unable to email each other, what is the minimum number of computers that must fail? Note that and cannot be destroyed. Please write a program to compute this minimum.
Consider the following network:
1*
/
3 - 2*
This figure shows computers with connections. We want to send messages between computers and . Computer is directly connected to , and is directly connected to . If computer fails, then and can no longer communicate.
Input Format
The first line contains four space-separated integers: . is the total number of computers, numbered from to . is the total number of connections. The last two integers and are the computers used by the two cows mentioned above. Connections have no duplicates and are undirected (i.e., if is connected to , then is connected to as well). There is at most one connection between any pair of computers. Computers and are not directly connected.
Lines to : each of the next lines contains the indices of two directly connected computers.
Output Format
One line containing a single integer: the minimum number of computers that must fail to make computers and unable to communicate with each other.
3 2 1 2
1 3
2 3
1
Hint
For of the testdata: , .
Translated by ChatGPT 5
京公网安备 11011102002149号