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

19022번 - Flow 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 256 MB64201850.000%

문제

We are considering a maximum flow problem on an infinite network.

You are given a bipartite graph $G$ with $n$ vertices in both parts and $m$ directed edges. Each edge goes from the left part to the right part, and has its capacity specified. We want to construct a family of networks $\{F_k\}$.

Here are the steps to construct the network $F_k$.

  • We first produce $k$ copies of the graph $G$. We call these copies $G_1, G_2, \ldots, G_k$.
  • For all 1ドル \leq i \leq k - 1$ and 1ドル \leq u \leq n,ドル we add a directed edge from $u$-th vertex in the right part of $G_i$ to $u$-th vertex in the left part of $G_{i + 1}$ with infinite capacity.
  • We add directed edges from the source to all the vertices in the left part of $G_1$ with infinite capacity.
  • We add directed edges from all the vertices in the right part of $G_k$ to the sink with infinite capacity.

Let $f_k$ be the maximum flow in the network $F_k$.

We want to know what the sequence $\{f_k\}$ looks like when $k$ goes to infinity. If $\{f_k\}$ does not converge to a constant, output $-1$. Otherwise, output $\lim\limits_{k \to +\infty} f_k$.

입력

The first line contains two integers $n$ and $m$ (1ドル \leq n \leq 2000,ドル 1ドル \leq m \leq 4000$).

Each of the following $m$ lines contains three integers $u,ドル $v,ドル and $w$ (1ドル \leq u, v \leq n,ドル 1ドル \leq w \leq 10^5$) which indicate that there is a directed edge from the $u$-th vertex in the left part to the $v$-th vertex in the right part with capacity $w$.

출력

If the sequence $\{f_k\}$ does not converge to a constant, output $-1$. Otherwise, output $\lim\limits_{k \to +\infty} f_k$.

제한

예제 입력 1

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

예제 출력 1

12

힌트

출처

Camp > Petrozavodsk Programming Camp > Summer 2018 > Day 8: Yuhao Du Contest 5, Grand Prix of Zhejiang F번

Contest > Open Cup > 2018/2019 Season > Stage 1: Grand Prix of Zheijang F번

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

출처

대학교 대회

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

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