Processing math: 100%
Power plant - MarisaOJ: Marisa Online Judge

Power plant

Time limit: 1000 ms
Memory limit: 256 MB
A country can be represented as a graph of n vertices and m edges, each vertex is a city. The government wants to build k power plant. The ith power plant is going to be built at city Ai and has the radius of Ri (cities having distance to Ai no more than Ri receive power from this plant). The government now wants to know how many cities have access to power. ### Input - The first line contains 3 integers n,m,k. - The next m lines, each line contains 2 integers u,v, there is an edge between u and v. - The next k lines, ith line contains 2 integers Ai,Ri. ### Output - Print the number of cities having access to power. ### Constraints - 1≤n,m,k≤105. - 1≤u,v,Ai,Ri≤n. ### Example Input: 65212133435261162 Output: 4