Potential well
시간 제한2초메모리 제한1024 MB
가중치가 있는 유향 그래프에서 각 정점에 퍼텐셜을 부여해 조정된 간선 가중치의 최솟값을 최대화하고, 무한히 크게 만들 수 있으면 +inf를 출력한다.
문제
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 will be assigned with its potential . If there was an edge from to with initial weight then its new weight will be .
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 () and () --- number of vertices and edges in Christian's favourite graph. Next lines contain triples of integers (, ) --- -th edge goes from to and has weight .
출력
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 by absolute value. Your answer should differ from the correct one and also from the answer computed based on your potentials no more than .