#x1063. CF449B Jzzhu and Cities

CF449B Jzzhu and Cities

Jzzhu and Cities

题面翻译

题意简述

nn 个点,mm 条带权边的无向图,另外还有kk 条特殊边,每条边连接11ii

问最多可以删除这kk 条边中的多少条,使得每个点到11 的最短距离不变。

输入

第一行3个数字n,m,kn,m,k

下面mm 行,每行3个数字ui,vi,xi(uivi)u_i,v_i,x_i(u_i\not= v_i)

再下面kk 行,每行两个数字si,yis_i,y_i ,代表连接1s1-s 的边,权值为yiy_i

数据范围

1ui,vi,sin1051 ≤ u_i,v_i,s_i ≤n ≤ 10^5

1k1051 ≤ k ≤ 10^5

1m3×1051 ≤ m ≤ 3\times 10^5

1xi,yi1091 ≤ x_i,y_i ≤ 10^9

感谢@wmxwmx 提供的翻译

题目描述

Jzzhu is the president of country A. There are n n cities numbered from 1 1 to n n in his country. City 1 1 is the capital of A. Also there are m m roads connecting the cities. One can go from city ui u_{i} to vi v_{i} (and vise versa) using the i i -th road, the length of this road is xi x_{i} . Finally, there are k k train routes in the country. One can use the i i -th train route to go from capital of the country to city si s_{i} (and vise versa), the length of this route is yi y_{i} .

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.

输入格式

The first line contains three integers n,m,k n,m,k (2<=n<=105;1<=m<=3105;1<=k<=105) (2<=n<=10^{5}; 1<=m<=3·10^{5}; 1<=k<=10^{5}) .

Each of the next m m lines contains three integers ui,vi,xi u_{i},v_{i},x_{i} $ (1<=u_{i},v_{i}<=n; u_{i}≠v_{i}; 1<=x_{i}<=10^{9}) $ .

Each of the next k k lines contains two integers si s_{i} and yi y_{i} (2<=si<=n;1<=yi<=109) (2<=s_{i}<=n; 1<=y_{i}<=10^{9}) .

It is guaranteed that there is at least one way from every city to the capital. Note, that there can be multiple roads between two cities. Also, there can be multiple routes going to the same city from the capital.

输出格式

Output a single integer representing the maximum number of the train routes which can be closed.

样例 #1

样例输入 #1

5 5 3
1 2 1
2 3 2
1 3 3
3 4 4
1 5 5
3 5
4 5
5 5

样例输出 #1

2

样例 #2

样例输入 #2

2 2 3
1 2 2
2 1 3
2 1
2 2
2 3

样例输出 #2

2