Find minimum s-t cut in a flow network
Submissions: 524   Accuracy: 14.72%   Difficulty: Medium   Marks: 4
Associated Course(s):   Sudo Placement [IITs]

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

** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Saksham Raj Seth
Author: saksham seth