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

31381번 - Potential well 스페셜 저지다국어

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

문제

Billionaire Christian has learned today about Dijkstra's algorithm with Johnson potentials. He liked it so much that he decided to add potentials to all of his favourite graphs.

Christian's tastes are very singular --- he keeps in his secret room only directed weighted graphs.

A little reminder about potentials: each vertex $v$ will be assigned with its potential $\phi(v)$. If there was an edge from $u$ to $v$ with initial weight $w$ then its new weight will be $w' = w - \phi(v) + \phi(u)$.

Strength of a graph is defined as a minimum of its edges weights.

Christian don't want weak graphs in his room, so he want to choose potentials in such way that its strength is maximized.

입력

First line contains two integers $n$ (2ドル \le n \le 10^3$) and $m$ (1ドル \le m \le 10^5$) --- number of vertices and edges in Christian's favourite graph. Next $m$ lines contain triples of integers $u_i,円 v_i,円 w_i$ (1ドル \le u_i,,円 v_i \le n,ドル $|w_i| \le 10^6$) --- $i$-th edge goes from $a_i$ to $b_i$ and has weight $w_i$.

출력

First line shoult contain maximum strength of the graph. If it is possible to make the answer infinitely big then output +inf instead.

If the answer is finite then second line should contain potentials of vertices. They shouldn't exceed 10ドル^{10}$ by absolute value. Your answer should differ from the correct one and also from the answer computed based on your potentials no more than 10ドル^{-5}$.

제한

예제 입력 1

3 3
1 2 1
2 3 1
3 1 1

예제 출력 1

1.0
0.0 0.0 0.0

예제 입력 2

2 1
1 2 1

예제 출력 2

+inf

힌트

출처

Contest > Open Cup > 2014/2015 Season > Stage 13: Grand Prix of Three Capitals I번

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

출처

대학교 대회

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

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