#P1345. [USACO5.4] 奶牛的电信 Telecowmunication

    ID: 342 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 7 上传者: 标签>图论USACO福建省历届夏令营网络流最小割

[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 cc computers a1,a2,,aca_1,a_2,\cdots ,a_c such that a1a_1 is connected to a2a_2, a2a_2 is connected to a3a_3, and so on, then computers a1a_1 and aca_c 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 c1c_1 and c2c_2 cannot be destroyed. Please write a program to compute this minimum.

Consider the following network:

   1*
  /
 3 - 2*

This figure shows 33 computers with 22 connections. We want to send messages between computers 11 and 22. Computer 11 is directly connected to 33, and 22 is directly connected to 33. If computer 33 fails, then 11 and 22 can no longer communicate.

Input Format

The first line contains four space-separated integers: N,M,c1,c2N, M, c_1, c_2. NN is the total number of computers, numbered from 11 to NN. MM is the total number of connections. The last two integers c1c_1 and c2c_2 are the computers used by the two cows mentioned above. Connections have no duplicates and are undirected (i.e., if c1c_1 is connected to c2c_2, then c2c_2 is connected to c1c_1 as well). There is at most one connection between any pair of computers. Computers c1c_1 and c2c_2 are not directly connected.

Lines 22 to M+1M+1: each of the next MM 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 c1c_1 and c2c_2 unable to communicate with each other.

3 2 1 2
1 3
2 3
1

Hint

For 100%100\% of the testdata: 1N1001 \le N \le 100, 1M6001 \le M \le 600.

Translated by ChatGPT 5