Find the Flow

4

5 votes
Easy, Flow
Problem

Given a directed flow network where each edge has a capacity of flow it could allow, find the maximum flow over the network from source(S) to sink(T).

Network will follow these rules:

  • Only one source(S) and only one sink(T).
  • Other than source and sink, nodes are represented with alphabets [AO].
  • There are no self loops.
  • There will be no initial dead ends other than T.
  • For any pair of nodes, direction of edges between them will be in single direction.

Input Format:
First line has an integer E- number of edges.
Next E lines have three values ViVjCx which implies there is a node from Vi to Vj with capacity Cx.

Output Format:
Print a single integer which is the maximum flow from source to sink.

Constraints:

  • 1E50
  • 1Cx50
  • Network includes S, T, a maximum of 15 other nodes.
Time Limit: 1
Memory Limit: 256
Source Limit:
Editor Image

?