Leaderboard
Showing:
Handle Score
@Ibrahim Nash 6381
@blackshadows 6329
@mb1973 5388
@Quandray 5231
@akhayrutdinov 5111
@saiujwal13083 4510
@sanjay05 3762
@marius_valentin_dragoi 3522
@sushant_a 3459
@verma_ji 3357
@KshamaGupta 3318
Complete Leaderboard
Find minimum s-t cut in a flow network
Medium Accuracy: 19.83% Submissions: 1005 Points: 4

Given an adjacency matrix and 2 integers S and T. The task is to find minimum capacity s-t cut of the given network. 
An s-t cut is a cut that requires the source ‘s’ and the sink ‘t’ to be in different subsets, and it consists of edges going from the source’s side to the sink’s side. The capacity of an s-t cut is defined by the sum of the capacity of each edge in the cut-set. 

Input:
The first line consists of T test cases. The first line of every test case consists of V number of vertices. The second line of every test case consists of V*V spaced integers consisting of the weight of edge from ith to jth index. The third line of every test case consists of S and T.

Output:
Single line output all the vertices which take the minimum cut from one vertex to other.If there is no mincut edge print -1.

Constraints:
1<=T<=10
1<=N<=50

Example:
Input:

1
6
0 16 13 0 0 0 0 0 10 12 0 0 0 4 0 0 14 0 0 0 9 0 0 20 0 0 0 7 0 4 0 0 0 0 0 0
0 5
Output:
1 3 4 3 4 5 

to report an issue on this page.

Editorial

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes

All Submissions

My Submissions:

Login to access your submissions.

Find minimum s-t cut in a flow network

Output Window