CF449B.Jzzhu and Cities

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Jzzhu is the president of country A. There are nn cities numbered from 11 to nn in his country. City 11 is the capital of A. Also there are mm roads connecting the cities. One can go from city uiu_{i} to viv_{i} (and vise versa) using the ii -th road, the length of this road is xix_{i} . Finally, there are kk train routes in the country. One can use the ii -th train route to go from capital of the country to city sis_{i} (and vise versa), the length of this route is yiy_{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,kn,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 mm lines contains three integers ui,vi,xiu_{i},v_{i},x_{i} (1<=ui,vi<=n; uivi; 1<=xi<=109)(1<=u_{i},v_{i}<=n; u_{i}≠v_{i}; 1<=x_{i}<=10^{9}) .

Each of the next kk lines contains two integers sis_{i} and yiy_{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

    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
    
首页