2651. How Many Paths Are There

单点时限: 2.0 sec

内存限制: 256 MB

oooccc1 is a Software Engineer who has to ride to the work place every Monday through Friday. For a long period, he went to office with the shortest path because he loves to sleep late…Time goes by, he find that he should have some changes as you could see, always riding with the same path is boring.

One day, oooccc1 got an idea! Why could I take another path? Tired at all the tasks he got, he got no time to carry it out. As a best friend of his, you’re going to help him!

Since oooccc1 is now getting up earlier, he is glad to take those paths, which are a little longer than the shortest one. To be precisely, you are going to find all the second shortest paths.

You would be given a direct graph G, together with the start point S which stand for oooccc’1 his house and target point E presents his office. And there is no cycle in the graph. Your task is to tell him how long are these paths and how many there are.

输入格式

There are some cases. Proceed till the end of file.

The first line of each case is three integers N, M, S, E (3 <= N <= 50, 0 <= S , E <N)

N for the nodes in that graph, M for the number of edges, S for the start point, and E for the end point.

Then follows M lines for the edges: x y w. x for the start point, and y for another point, w for the length between. All the nodes are marked from 0 through N-1.

输出格式

For each case print the length and count for those second shortest paths in one line. Separate them with a single space.

样例

Input
3 3 0 2
0 2 5
0 1 4
1 2 2
Output
6 1

6 人解决,22 人已尝试。

8 份提交通过,共有 106 份提交。

8.5 EMB 奖励。

创建: 11 年,5 月前.

修改: 3 年,5 月前.

最后提交: 2 年,9 月前.

来源: N/A

题目标签