Codeforces Round 265 (Div. 1)
E
The Classic Problem
Codeforces
3000
原题
← D→
翻译中…

You are given a weighted undirected graph on $n$ vertices and $m$ edges. Find the shortest path from vertex $s$ to vertex $t$ or else state that such path doesn't exist.

翻译中…

Input

翻译中…

The first line of the input contains two space-separated integers — $n$ and $m$ ($1 \leq n \leq 10^5$; $0 \leq m \leq 10^5$).

翻译中…

Next $m$ lines contain the description of the graph edges. The $i$-th line contains three space-separated integers — $u_i$, $v_i$, $x_i$ ($1 \leq u_i, v_i \leq n$; $0 \leq x_i \leq 10^5$). That means that vertices with numbers $u_i$ and $v_i$ are connected by edge of length $2^{x_i}$ (2 to the power of $x_i$).

翻译中…

The last line contains two space-separated integers — the numbers of vertices $s$ and $t$.

翻译中…

The vertices are numbered from $1$ to $n$. The graph contains no multiple edges and self-loops.

翻译中…

Output

翻译中…

In the first line, print the remainder after dividing the length of the shortest path by $1000\,000\,007$ ($10^9 + 7$) if the path exists, and $-1$ if the path doesn't exist.

翻译中…

If the path exists, print in the second line integer $k$ — the number of vertices in the shortest path from vertex $s$ to vertex $t$; in the third line print $k$ space-separated integers — the vertices of the shortest path in the visiting order. The first vertex should be vertex $s$, the last vertex should be vertex $t$. If there are multiple shortest paths, print any of them.

翻译中…

Note

翻译中…

A path from vertex $s$ to vertex $t$ is a sequence $v_0$, ..., $v_k$, such that $v_0 = s$, $v_k = t$, and for any $i$ from 0 to $k - 1$ vertices $v_i$ and $v_{i+1}$ are connected by an edge.

翻译中…

The length of the path is the sum of weights of edges between $v_i$ and $v_{i+1}$ for all $i$ from 0 to $k - 1$.

翻译中…

The shortest path from $s$ to $t$ is the path which length is minimum among all possible paths from $s$ to $t$.

翻译中…

样例

Input #1
4 4
1 4 2
1 2 0
2 3 0
3 4 0
1 4
Output #1
3
4
1 2 3 4
InputCopy OutputCopy
Input #2
4 3
1 2 4
2 3 5
3 4 6
1 4
Output #2
112
4
1 2 3 4
InputCopy OutputCopy
Input #3
4 2
1 2 0
3 4 1
1 4
Output #3
-1
InputCopy OutputCopy
题目信息
题号
464E
时间限制
5 s
内存限制
768 MB
标签
数据结构
图论
最短路

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。