#P10698. [SNCPC2024] 最大流

[SNCPC2024] 最大流

Problem Description

Given a directed acyclic graph with nn vertices and mm edges, where the capacity of each edge is 11. For every vertex ii except vertex 11, let the maximum flow from vertex 11 to vertex ii be fif_i. Compute min{fi, k}\min\{f_i,\ k\}.

In a graph where every edge has capacity 11, a flow from vertex 11 to vertex ii is a path from vertex 11 to vertex ii. If there can be at most fif_i edge-disjoint flows from vertex 11 to vertex ii at the same time (that is, no edge belongs to two flows), then we say the maximum flow from vertex 11 to vertex ii is fif_i.

Input Format

The first line contains three integers n,m,kn, m, k ($2 \leq n \leq 10^5, 1 \leq m \leq 2 \times 10^5, 1 \leq k \leq 50$), separated by spaces, representing the number of vertices, the number of edges, and the parameter.

The next mm lines each contain two integers xi,yix_i,y_i (1xi,yin,xiyi1 \leq x_i, y_i \leq n, x_i \neq y_i), separated by spaces, describing a directed edge.

The graph is guaranteed to have no self-loops, but it may contain multiple edges. It is guaranteed to be a directed acyclic graph.

Output Format

Output exactly one line containing n1n-1 integers, separated by spaces. For the ii-th integer, if the maximum flow from vertex 11 to vertex i+1i+1 does not exceed kk, output its value; otherwise output kk.

7 12 3
1 2
1 3
3 2
3 4
2 4
1 5
5 6
3 6
1 7
5 7
6 7
4 7

2 1 2 1 2 3 

5 8 50
1 2
1 2
1 2
3 2
2 4
2 4
2 4
2 4

3 0 3 0 

Hint

The graph in the first sample is shown below:

We can find 44 edge-disjoint paths from vertex 11 to vertex 77:

1->7\text{1->7}

1->5->7\text{1->5->7}

1->3->6->7\text{1->3->6->7}

1->2->4->7\text{1->2->4->7}

We cannot find any more edge-disjoint paths from vertex 11 to vertex 77.

So the maximum flow from vertex 11 to vertex 77 is f7=4f_7=4, but since k=3k=3, the sixth integer in the answer is 33.

Translated by ChatGPT 5