QOJ.ac

QOJ

Límite de tiempo: 3.0 s Límite de memoria: 1024 MB Puntuación total: 100 Hackeable ✓

#457. Maximum Flow 2

Estadísticas

This is the hard version of the maximum flow problem.

Given $n$ nodes and $m$ edges, with the capacity of each edge provided, find the maximum flow from node $s$ to node $t$.

Input

The first line contains four integers $n, m, s, t$.

The next $m$ lines each contain three integers $u, v, c$, representing an edge from $u$ to $v$ with capacity $c$.

Output

Output the maximum flow from node $s$ to node $t$.

Examples

Input 1

7 14 1 7
1 2 5
1 3 6
1 4 5
2 3 2
2 5 3
3 2 2
3 4 3
3 5 3
3 6 7
4 6 5
5 6 1
6 5 1
5 7 8
6 7 7

Output 1

14

Subtasks

For all data, $1 \leq n \leq 2\,000$, $1 \leq m \leq 3.2 \cdot 10^5$, $1 \leq c \leq 10^9$.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.