Jzzhu and Cities

题意翻译

## 题意简述 $n$ 个点,$m$ 条带权边的无向图,另外还有$k$ 条特殊边,每条边连接$1$ 和$i$ 。 问最多可以删除这$k$ 条边中的多少条,使得每个点到$1$ 的最短距离不变。 ## 输入 第一行3个数字$n,m,k$ 下面$m$ 行,每行3个数字$u_i,v_i,x_i(u_i\not= v_i)$ 再下面$k$ 行,每行两个数字$s_i,y_i$ ,代表连接$1-s$ 的边,权值为$y_i$ ## 数据范围 $1 ≤ u_i,v_i,s_i ≤n ≤ 10^5$ $1 ≤ k ≤ 10^5$ $1 ≤ m ≤ 3\times 10^5$ $1 ≤ x_i,y_i ≤ 10^9$ 感谢@wmxwmx 提供的翻译

题目描述

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} $ to $ v_{i} $ (and vise versa) using the $ i $ -th road, the length of this road is $ x_{i} $ . Finally, there are $ k $ train routes in the country. One can use the $ i $ -th train route to go from capital of the country to city $ s_{i} $ (and vise versa), the length of this route is $ 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 $ $ (2<=n<=10^{5}; 1<=m<=3·10^{5}; 1<=k<=10^{5}) $ . Each of the next $ m $ lines contains three integers $ 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 $ lines contains two integers $ s_{i} $ and $ y_{i} $ $ (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

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 3
1 2 2
2 1 3
2 1
2 2
2 3

输出样例 #2

2