#P7437. 既见君子
既见君子
Description
The campus can be seen as a connected undirected graph with vertices and undirected edges (multiple edges may exist, no self-loops). The vertices are numbered from to . The school gate is at vertex , the computer lab is at vertex , and Teacher Tu’s office is at vertex ().
However, staff members (actually Sakura Hatsune) block of the edges, so that the remaining graph (including all vertices and the remaining edges) is still connected. At this time, between any two vertices there is exactly one simple path. The staff will choose a blocking plan uniformly at random. (If , then no edges are blocked and the graph stays unchanged.)
Of course, wygz does not want Teacher Tu’s office to appear on her unavoidable route. Please compute the probability that the path from the school gate to the computer lab must pass through Teacher Tu’s office. Output the answer modulo .
Input Format
The first line contains three positive integers , , and , representing the number of vertices, the number of edges, and the location of Teacher Tu’s office.
The next lines each contain two positive integers , , indicating an undirected edge connecting and .
Output Format
Output one line with one non-negative integer, representing the answer modulo .
4 5 2
1 2
1 3
2 3
2 4
3 4
374341633
6 8 4
1 2
1 3
2 3
2 4
2 5
4 5
4 6
5 6
374341633
Hint
Sample Explanation:
Sample #1: There are spanning trees in total, and of them satisfy that the path from to passes through . .
Sample #2: There are spanning trees in total, and of them satisfy that the path from to passes through . .
Constraints:
| Test Point ID | ||
|---|---|---|
For of the testdata, , , and .
The testdata guarantees that the number of spanning trees of the input graph modulo is non-zero.
Translated by ChatGPT 5
京公网安备 11011102002149号