#P10809. [LMXOI Round 2] Nirvana
[LMXOI Round 2] Nirvana
Background
HQZ is tinkering with a machine made by LMX.
Problem Description
An undirected connected graph is defined to be good if and only if there exists an orientation of all edges such that the original graph can be turned into a directed acyclic graph in which only has in-degree and only has out-degree .
Given an undirected connected graph with vertices and edges, with no self-loops, define one operation as choosing two (possibly identical) vertices uniformly at random with , and adding an edge between and . Let be the probability that the graph after one operation is good. Output .
If , you need to construct an orientation after adding one edge.
If , you need to construct a plan that deletes the minimum number of vertices so that the original graph becomes good.
Input Format
The first line contains four positive integers , as described above.
The next lines each contain two positive integers , indicating an undirected edge between and .
Output Format
The first line contains a non-negative integer .
If , output the next two lines. The first of these lines contains two positive integers , indicating that the edge you add is the directed edge . The second line contains a string of length consisting only of and . If , then the direction of edge is ; otherwise it is .
If , output the next two lines. The first of these lines contains a positive integer , indicating the minimum number of vertices to delete. The second line contains positive integers, indicating the vertices to delete.
Scoring:
If the output format is correct, then if your program correctly outputs the probability , you will get of the score for that test point.
On top of that, if you also construct a correct plan, you will get of the score for that test point.
If your program has an incorrect output format, unexpected errors may occur.
5 8 1 4
1 2
2 3
3 4
4 5
1 3
1 4
2 4
3 5
665496236
1 2
00010000
6 5 5 6
1 2
1 3
1 4
1 5
1 6
0
3
2 3 4
9 9 1 7
1 3
2 3
3 4
3 5
4 5
4 6
5 7
4 8
8 9
0
4
2 6 8 9
Hint
For all data, .
update 7/27: Subtask #7 is new hack testdata. The constraints are the same as Subtask #6.
| Subtask # | Special Property | Score | ||
|---|---|---|---|---|
| Subtask #1 | None | |||
| Subtask #2 | ||||
| Subtask #3 | The original graph is a cycle | |||
| Subtask #4 | None | |||
| Subtask #5 | ||||
| Subtask #6 | None | |||
Translated by ChatGPT 5