1063题没有数据范围,而且以前AC的代码交上去RE16,样例也过不了
用bellman_ford算法求单源最短路径。
输入格式:
第一行两个整数s,t
第二行两个整数n,m
以下m行每行三个整数a,b,c,表示a,b之间有边,且边的权值为c
输出格式:
s到t的最短路,并输出路径(按字典序输出最小的一条)
如果存在负权回路输出You show me the wrong map!
样例输入:
1 3
5 7
1 2 6
1 4 2
1 5 23
2 3 4
4 2 -3
3 4 20
3 5 -7
样例输出:
3
1 4 2 3
时间限制:
1000
空间限制:
65536
Use the bellman_ford algorithm to find the single source shortest path.
Input :
The first line two integers s,t
The second line two integers n,m
The following m lines have three integers a, b, and c for each line, indicating that there is an edge between a and b, and the weight of the edge is c.
Output:
The shortest path from s to t, and the output path (the smallest one in lexicographic order)
If there is a negative loop , output You show me the wrong map!
Sample input:
1 3
5 7
1 2 6
1 4 2
1 5 23
2 3 4
4 2 -3
3 4 20
3 5 -7
Sample output:
3
1 4 2 3
time limit:
1000
Memory Limit:
65536