题目链接:https://www.luogu.org/problemnew/show/P2984
Description:
Farmer John有B头牛(1<=B<=25000),有N(2*B<=N<=50000)个农场,编号1-N,有M(N-1<=M<=100000)条双向边,第i条边连接农场R_i和S_i(1<=R_i<=N;1<=S_i<=N),该边长L_i(1<=L_i<=2000)。住在农场P_i的奶牛A(1<=P_i<=N),它想送一份新物给在农场Q_i(1<=Q_i<=N)的奶牛B,但奶牛A必须先到FJ(居住在编号1的农场)那取礼物,然后送给奶牛B。求:奶牛A至少需要走多远的路程?
Sample Input
6 7 3
1 2 3
5 4 3
3 1 1
6 1 9
3 4 2
1 4 4
3 2 2
2 4
5 1
3 6
Sample Output
6
6
10
思路
拿到这题,第一反应是最短路