logo AlgoBeat OnlineJudge
登录 注册

#213748. [NWRRC 2021] Kaleidoscopic Route

内存限制:512 MiB 时间限制:2000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

There are cities in Kaleidostan connected with bidirectional roads. The cities are numbered from to . Each road has an integer called .

Keanu wants to travel from city to city . He wants to take the route --- that is, the route with the smallest number of roads. Among all the shortest routes, he wants to take the 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 and --- the number of cities and the number of roads (; ).

The -th of the following lines contains three integers , , and --- the indices of the cities connected by the -th road, and the colorfulness of the -th road (; ; ).

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 --- the number of roads in the required route.

In the second line, print integers --- the sequence of cities on the route (; ; ).

样例

样例输入 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 roads, and the difference between the maximum and the minimum colorfulnesses of its roads is .