Is Dinic quartic?
Time limit2sMemory limit512 MB
Print a fixed 4-vertex, 5-edge flow network with the exact edges and capacities given in the statement.
- Level
Easy1 of 10
- Topics
- Graph, Implementation, Simulation
- Solved
- No attempts yet
Problem
Jigoo always solves maximum-flow problems with the Edmonds-Karp algorithm. One day Jigoo saw a flow problem with vertices and edges. Jigoo built a flow graph, wrote about bytes of code, and submitted it, but the cheerful green "Accepted!!" text did not appear. Tired of optimizing the code, Jigoo found Dinic's algorithm, whose worst-case time complexity is .
Dinic's algorithm is simpler than it first seems.
- Treat every residual edge as an edge of length , and compute the shortest distance from the source to every vertex.
- Find an augmenting path by DFS and send flow. Use an edge only when .
- Repeat steps 1 and 2 until no more flow can be sent.
The time complexity of Dinic is . The proof is as follows.
- Steps 1 and 2 repeat at most times.
- Reason: each round increases the distance to the sink by at least , and cannot exceed .
- Step 1 is .
- Reason: it can be computed by BFS.
- Step 2 is .
- Reason: each time flow is sent, at least one edge becomes saturated, so at most augmenting paths are created. The length of an augmenting path is at most .
There was still a problem. Jigoo implemented the algorithm carefully and still did not see the green text. In the end Jigoo gave up on that problem together with Dinic.
A few days later, Dotori happened to look at Jigoo's Dinic code and pointed out a small mistake that caused many useless operations and made the program slow. Jigoo fixed the code and finally saw the beautiful green text.
Jigoo still found something odd. The number of edges is at most , so Dinic is , and vertices should time out. Jigoo could not construct a slow test.
Originally any flow graph that makes Dinic slow would be accepted. To fix a unique answer, print the following graph.
There are vertices and edges. Flow is sent from vertex to vertex . Print the edges in this order with these capacities.
- , capacity
- , capacity
- , capacity
- , capacity
- , capacity
Input
There is no input. If standard input is present, ignore it.
Output
Print the number of vertices and the number of edges on the first line, separated by a space.
On each of the next lines, print the start vertex , the end vertex , and the capacity , separated by spaces.
The output must be exactly , , with the edges in the order and capacities fixed in the statement.