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

1 3 4 3 4 5

Author: saksham seth

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

vkpm | 22 |

Phenix_Fire | 18 |

shubhangi_upasani | 18 |

sajnanair | 16 |

EshaAgarwal | 16 |

Pulkit__Sharma__ | 806 |

Anirban166 | 682 |

Found_me | 616 |

abducodes | 607 |

Sathvik Avasarala | 518 |

blackshadows | 5331 |

Ibrahim Nash | 5219 |

akhayrutdinov | 5111 |

mb1973 | 4929 |

Quandray | 4559 |

Login to report an issue on this page.