#P5492. [PKUWC2018] 随机算法
[PKUWC2018] 随机算法
Description
We know that finding the maximum independent set of an arbitrary graph is an NP-complete problem. Currently, there is no exact polynomial-time algorithm, but there are many polynomial-time approximation algorithms.
For example, one algorithm often used by Little C is:
-
For an undirected graph with vertices, first uniformly randomly generate a permutation of .
-
Maintain an answer set . Initially, is empty. Then, in the order , check whether is an independent set. If it is, set .
-
Finally, obtain an independent set as the answer.
Now Little C wants to know, for a given graph, the probability that this algorithm is correct. Output the answer modulo .
Input Format
The first line contains two non-negative integers , representing the number of vertices and edges of the given graph.
The next lines each contain two positive integers , describing an undirected edge of the graph.
Output Format
Output the probability of being correct, modulo .
3 2
1 2
2 3
665496236
Hint
Sample Explanation
The maximum independent set size of this graph is clearly . It can be seen that only when will we get ; otherwise, we always get . Therefore, the answer is .
Constraints
For of the testdata, .
For of the testdata, .
For of the testdata, .
Another of the testdata satisfies that the given graph is a path.
Another of the testdata satisfies that the given graph is a tree.
For of the testdata, , . It is guaranteed that the given graph has no multiple edges and no self-loops.
Translated by ChatGPT 5
京公网安备 11011102002149号