QOJ.ac

QOJ

حد الوقت: 1.0 s حد الذاكرة: 256 MB مجموع النقاط: 100 قابلة للهجوم ✓

#456. Maximum Flow 1

الإحصائيات

This is a simple version of the maximum flow problem. You can expect a correctly implemented Dinic's algorithm or other similar algorithms to pass this 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 test cases, $1 \leq n \leq 500$, $1 \leq m \leq 20\,000$, $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.