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

24648번 - Kaleidoscopic Route 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 (추가 시간 없음) 512 MB104212024.390%

문제

There are $n$ cities in Kaleidostan connected with $m$ bidirectional roads. The cities are numbered from 1ドル$ to $n$. Each road has an integer called colorfulness.

Keanu wants to travel from city 1ドル$ to city $n$. He wants to take the shortest route --- that is, the route with the smallest number of roads. Among all the shortest routes, he wants to take the kaleidoscopic one --- that is, the route with the largest possible difference between the maximum and the minimum colorfulnesses of its roads. Help Keanu find such a route.

입력

The first line contains two integers $n$ and $m$ --- the number of cities and the number of roads (2ドル \le n \le 10^5$; 1ドル \le m \le 2 \cdot 10^5$).

The $i$-th of the following $m$ lines contains three integers $v_i,ドル $u_i,ドル and $c_i$ --- the indices of the cities connected by the $i$-th road, and the colorfulness of the $i$-th road (1ドル \le v_i, u_i \le n$; $v_i \neq u_i$; 0ドル\le c_i \le 10^9$).

Each pair of cities is connected by at most one road. It is guaranteed that you can travel from any city to any other city using the roads.

출력

In the first line, print a single integer $k$ --- the number of roads in the required route.

In the second line, print $k+1$ integers $c_0, c_1, \ldots, c_k$ --- the sequence of cities on the route (1ドル \le c_i \le n$; $c_0 = 1$; $c_k = n$).

제한

예제 입력 1

6 8
1 5 2
5 2 5
3 5 4
1 3 10
3 4 6
4 5 7
4 6 8
2 6 1

예제 출력 1

3
1 5 4 6 

힌트

In the example test, the required route consists of 3ドル$ roads, and the difference between the maximum and the minimum colorfulnesses of its roads is 8ドル-2=6$.

출처

ICPC > Regionals > Northern Eurasia > Northwestern Russia Regional Contest > ICPC 2021-2022 North-Western Russia Regional Contest K번

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

출처

대학교 대회

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

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