#P7733. Lab Data Rescue
Lab Data Rescue
Lab Data Rescue
The experimental center can be modeled as an undirected connected graph with \(n\) vertices and \(m\) edges. All experimenters start at the hall \(s\) and each second they may move to an adjacent lab and collect the data therein. Meanwhile, the toxic gas spreads every second from every contaminated lab to all of its adjacent labs.
When an experimenter returns to the hall \(s\), we say he has rescued the data from that lab. However, an experimenter may not enter any lab that is already contaminated by toxic gas (entering a lab in the same second as the gas also is not allowed).
Note: The hall is surrounded by strict protective measures so that neither the hall \(s\) nor its adjacent labs (except possibly the gas leak starting point \(t\)) will be affected by the toxic gas spread. At time \(0\), all experimenters are at \(s\), and the gas leak starts at lab \(t\). Assuming there are enough experimenters to cover all possibilities, what is the maximum number of labs from which data can be rescued?
Hint: For any lab \(x\) (other than those protected), if the minimum distance from \(s\) to \(x\) is \(d_s(x)\) and the minimum distance from \(t\) to \(x\) is \(d_t(x)\), then the lab can be rescued if and only if \(2\,d_s(x) < d_t(x)\). Labs which are in the protected area (the hall \(s\) and its adjacent labs, provided they are not the initial gas leak point \(t\)) can always be rescued.
inputFormat
The first line contains four integers \(n\), \(m\), \(s\), and \(t\) (\(1 \leq s, t \leq n\)). Then follow \(m\) lines, each containing two integers \(u\) and \(v\) indicating that there is an undirected edge between labs \(u\) and \(v\).
You may assume that the graph is connected and does not contain self-loops or multiple edges.
outputFormat
Output a single integer: the maximum number of labs whose data can be rescued.
sample
4 4 1 4
1 2
2 3
3 4
1 4
2