最短路专题2 | CodeForces 449B - SPFA算法
B. Jzzhu and Cities
Jzzhu is the president of country A. There are n cities numbered from 1 to n in his country. City 1 is the capital of A. Also there are m roads connecting the cities. One can go from city u i u_i ui to v i v_i vi (and vise versa) using the i i i-th road, the length of this road is x i x_i xi. Finally, there are k train routes in the country. One can use the i i i-th train route to go from capital of the country to city s i s_i si (and vise versa), the length of this route is y i y_i yi.
J是A国的总统,这个国家有n个城市。1是首都,有m条公路连接这些城市。然后,有k个火车线。城市 s i s_i si到首都1的距离是 y i y_i yi。
Jzzhu doesn’t want to waste the money of the country, so he is going to close some of the train routes. Please tell Jzzhu the maximum number of the train routes which can be closed under the following condition: the length of the shortest path from every city to the capital mustn’t change.
J不想浪费钱,删除部分铁路,但是每个城市到达首都的最短路径不能被修改,也就是说,只有最短路径不经过这个铁路时,才可以删除。
Input
The first line contains three integers n , m , k ( 2 ≤ n ≤ 105 ; 1 ≤ m ≤ 3 ⋅ 105 ; 1 ≤ k ≤ 105 ) n, m, k (2 ≤ n ≤ 105; 1 ≤ m ≤ 3·105; 1 ≤ k ≤ 105) n, m, k(2 ≤