Geeksforgeeks

Error

×

Leaderboard

Showing:

Handle | Score |
---|---|

@Ibrahim Nash | 6379 |

@blackshadows | 6329 |

@mb1973 | 5358 |

@Quandray | 5231 |

@akhayrutdinov | 5111 |

@saiujwal13083 | 4510 |

@sanjay05 | 3762 |

@marius_valentin_dragoi | 3522 |

@sushant_a | 3459 |

@verma_ji | 3357 |

@KshamaGupta | 3318 |

Complete Leaderboard | |

Handle | Score |

@ritiksethi21 | 1050 |

@aroranayan999 | 807 |

@RizulBansal | 685 |

@ashishtrehan002 | 538 |

@hemantgarg923 | 528 |

@simrangoyal | 526 |

@ronaldo77 | 520 |

@thanosagain | 505 |

@anishrajan | 505 |

@ssparteek470 | 495 |

@rahul2312 | 491 |

Complete Leaderboard |

Given a graph with N vertices numbered 1 to N and M edges, the task is to find the max flow from vertex 1 to vertex N.

**Input:**

The first line of input contains an integer T denoting the no of test cases. Then T test cases follow. The first line of each test case contains two space separated integers N and M . Then in the next line are M space separated triplets x, y, z denoting an undirected edge from x to y with a flow capacity of z.

**Output:**

For each test case in a new line print a single integer denoting the maximum flow between 1 to N.

**Constraints:**

1<=T<=100

1<=N,M<=1000

**Example:
Input:**

2

5 4

1 2 1 3 2 2 4 2 3 2 5 5

4 4

1 2 8 1 3 10 2 4 2 3 4 3

1

5

Login to report an issue on this page.

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

Yes
Find the Maximum Flow

...