#P9901. 『PG2』弯曲半平面直线同向图最大流
『PG2』弯曲半平面直线同向图最大流
Problem Description
If a directed graph can be drawn on the plane such that all vertices lie on one straight line, any two edges (which may be curved arcs) intersect only at shared vertices, all points on every edge lie on the same side of the line, and the ray direction from the start point to the end point of each edge is the same, then is called a curved half-plane collinear same-direction graph. Given vertices and directed edges in such a graph, along with the capacity of each edge, find the maximum flow from vertex to vertex .
Input Format
The first line contains four positive integers , , , and , separated by spaces, representing the number of vertices, the number of directed edges, the index of the source vertex, and the index of the sink vertex.
The next lines each contain three positive integers , , and , separated by spaces, indicating that the -th directed edge starts from , ends at , and has capacity .
Output Format
Output one integer, representing the maximum flow from to .
5 7 1 5
1 2 1
2 3 1
3 4 1
4 5 1
2 4 1
1 4 1
1 5 1
2
Hint
There are no multiple edges or self-loops.
For of the testdata, .
For of the testdata, .
For of the testdata, , $1 \leq m \leq \min\{2\times 10^9,\dfrac{n(n-1)}{2}\}$, , and .
Sample Explanation 1

Translated by ChatGPT 5