#graph1006. 最小割
最小割
Minimum Cut
Problem Source
AHOI 2009
Problem Description
Countries A and B are at war. In country A's material transport network there are transit stations and one-way roads. Suppose the -th road () connects transit stations and ; then transit station can reach transit station via this road, and cutting this road costs .
Now country B wants to find a set of roads to cut so that transit station can no longer reach transit station , while minimizing the total cutting cost.
Little Cocoa immediately saw that this is a minimum-cut problem. But the thoughtful Little Cocoa is not satisfied with just that. For each one-way road he now raises two questions:
- Question 1: Is there a minimum-cost cutting plan in which this road is cut?
- Question 2: Is this road cut in every minimum-cost cutting plan?
Please answer these two questions for each road.
Input Format
The first line contains four positive integers ().
Lines to each contain three positive integers , indicating a one-way road from transit station to transit station with cutting cost ().
Note: there may be multiple roads directly connecting the same pair of transit stations.
Output Format
For each one-way road, in the order they were input, output one line containing two integers that are each either or , representing the answers to question 1 and question 2 respectively ( means yes, means no).
Sample Input
6 7 1 6
1 2 3
1 3 2
2 4 4
2 5 1
3 5 5
4 6 2
5 6 3
Sample Output
1 0
1 0
0 0
1 0
0 0
1 0
1 0
Hint
Let the edge from the -th input line be edge . Then are the only three minimum-cost cutting plans. Their union is , and their intersection is .