#P7437. 既见君子

    ID: 6259 远端评测题 1500ms 500MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>O2优化状态压缩,状压生成树线性代数高斯消元

既见君子

Description

The campus can be seen as a connected undirected graph with nn vertices and mm undirected edges (multiple edges may exist, no self-loops). The vertices are numbered from 11 to nn. The school gate is at vertex 11, the computer lab is at vertex nn, and Teacher Tu’s office is at vertex zz (z1,nz\ne 1,n).

However, staff members (actually Sakura Hatsune) block mn+1m-n+1 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 m=n1m=n-1, 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 998244353998244353.

Input Format

The first line contains three positive integers nn, mm, and zz, representing the number of vertices, the number of edges, and the location of Teacher Tu’s office.

The next mm lines each contain two positive integers uu, vv, indicating an undirected edge connecting uu and vv.

Output Format

Output one line with one non-negative integer, representing the answer modulo 998244353998244353.

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 88 spanning trees in total, and 55 of them satisfy that the path from 11 to 44 passes through 22. 58374341633(mod998244353)\dfrac 5 8\equiv 374341633\pmod {998244353}.

Sample #2: There are 2424 spanning trees in total, and 1515 of them satisfy that the path from 11 to 66 passes through 44. 1524374341633(mod998244353)\dfrac {15} {24}\equiv 374341633\pmod {998244353}.

Constraints:

Test Point ID nn mm
11 =3=3 5\le 5
22 105\le 10^5
3,43,4 =7=7 15\le 15
5,65,6 105\le 10^5
77 =20=20 =n1=n-1
8,98,9 =n=n
10,11,1210,11,12 =18=18 105\le 10^5
13,14,15,1613,14,15,16 =19=19
17,18,19,2017,18,19,20 =20=20

For 100%100\% of the testdata, 3n203\le n\le 20, n1m105n-1\le m\le 10^5, z1z\ne 1 and znz\ne n.

The testdata guarantees that the number of spanning trees of the input graph modulo 998244353998244353 is non-zero.

Translated by ChatGPT 5