Problem D. Shortest-path tree
时间限制 3000 ms
内存限制 127.6484375 MB
Given a connected, undirected graph G, a shortest-path tree rooted at vertex v is a spanning tree T of G, such that the path distance from root v to any other vertex u in T is the shortest path distance from v to u in G.
We may construct a shortest-path tree using the following method:
We consider a shortest-path tree rooted at node 1. For every node i in the graph G, we choose a shortest path from root to i. If there are many shortest paths from root to i, we choose the one that the sequence of passing nodes' number is lexicographically minimum. All edges on the paths that we chose form a shortest-path tree.
Now we want to know how long are the longest simple paths which contain K nodes in the shortest-path tree and how many these paths? Two simple paths are different if the sets of nodes they go through are different.
输入数据
输出数据
For each case, output two numbers, denote the length of required paths and the numbers of required paths.
样例输入
复制
1
6 6 4
1 2 1
2 3 1
3 4 1
2 5 1
3 6 1
5 6 1
样例输出
$ Mathjax font initiator $