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

19111번 - Two Paths 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 512 MB84443751.389%

문제

You are given an undirected graph with $n$ nodes (numbered from 1ドル$ to $n$) and $m$ edges. Each edge has a length. The graph contains neither multiple edges nor self-loops.

Alice and Bob are now trying to play a game. Each player has to pick a path from 1ドル$ to $n$ (not necessary a simple path). The paths have to be different.

Alice always moves first, and she is so clever that she took one of the shortest paths from 1ドル$ to $n$. Now is Bob's turn. Bob wants to pick the shortest possible path from 1ドル$ to $n$ which is different from Alice's path. Your task is to find the length of such path.

Two paths $S$ and $T$ are considered different if and only if they have different number of edges or there is an integer $i$ such that the $i$-th edge of $S$ differs from the $i$-th edge of $T$.

입력

The first line of input contains two integers: the number of nodes $n$ and the number of edges $m$ (2ドル \le n \le 10^5,ドル 1ドル \le m \le 10^5$). Each of the next $m$ lines contains three integers $a,ドル $b,ドル and $w$ which mean that there is an edge between node $a$ and node $b,ドル and its length is $w$ (1ドル \le a, b \le n,ドル 1ドル \le w \le 10^9$). It is guaranteed that there is at least one path from 1ドル$ to $n$.

출력

Print a single line with a single integer: the length of a valid shortest path for Bob.

제한

예제 입력 1

3 3
1 2 1
2 3 4
1 3 3

예제 출력 1

5

예제 입력 2

2 1
1 2 1

예제 출력 2

3

힌트

출처

Camp > Petrozavodsk Programming Camp > Summer 2017 > Day 7: DPRK Contest 2 K번

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

출처

대학교 대회

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

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