Codeforces Round 257 (Div. 2)
D
Jzzhu and Cities
Codeforces
未评级
原题
← C→
翻译中…

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.

翻译中…

Input

翻译中…

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

翻译中…

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

翻译中…

样例

Input #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
Output #1
2
InputCopy OutputCopy
Input #2
2 2 3
1 2 2
2 1 3
2 1
2 2
2 3
Output #2
2
InputCopy OutputCopy
题目信息
题号
450D
时间限制
2 s
内存限制
256 MB

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。