Logo
(追記) (追記ここまで)

23455번 - Flow 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 (추가 시간 없음) 256 MB833100.000%

문제

One of Pang's research interests is the maximum flow problem.

A directed graph $G$ with $n$ vertices is universe if the following condition is satisfied:

  • $G$ is the union of $k$ vertex-independent simple paths from vertex 1ドル$ to vertex $n$ of the same length.

A set of paths is vertex-independent if they do not have any internal vertex in common.

A vertex in a path is called internal if it is not an endpoint of that path.

A path is simple if its vertices are distinct.

Let $G$ be a universe graph with $n$ vertices and $m$ edges. Each edge has a non-negative integral capacity. You are allowed to perform the following operation any (including 0ドル$) times to make the maximum flow from vertex 1ドル$ to vertex $n$ as large as possible:\\

Let $e$ be an edge with positive capacity. Reduce the capacity of $e$ by 1ドル$ and increase the capacity of another edge by 1ドル$.\\

Pang wants to know what is the minimum number of operations to achieve it?

입력

The first line contains two integers $n$ and $m$ (2ドル\leq n\leq 100000, 1\leq m \leq 200000$).

Each of the next $m$ lines contains three integers $x, y$ and $z,ドル denoting an edge from $x$ to $y$ with capacity $z$ (1ドル \leq x, y \leq n,ドル 0ドル\le z\le 1000000000$).

It's guaranteed that the input is a $universe$ graph without multiple edges and self-loops.

출력

Output a single integer --- the minimum number of operations.

제한

예제 입력 1

4 3
1 2 1
2 3 2
3 4 3

예제 출력 1

1

예제 입력 2

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

예제 출력 2

1

힌트

출처

Contest > Open Cup > 2019/2020 Season > Stage 10: Grand Prix of Xi’An E번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /