F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

City

Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 391    Accepted Submission(s): 134


Problem Description
Lucida occupies $n$ cities connected by $m$ undirected roads, and each road has a strength $k_i$. The enemy will attack to destroy these roads. When the enemy launches an attack with damage $x$, all roads with strength less than $x$ will be destroyed.

Now Lucida has $Q$ questions to ask you, how many pairs of cities are reachable to each other if the enemy launches an attack with damage $p_i$. City $x$ and city $y$ are reachable, which means that there is a path from $x$ to $y$, and every road's strength in that path is greater than or equal to $p_i$.
 

Input
This problem contains multiple test cases.

The first line contains a single integer $T$ ($1\leq T \leq 10$).

Then $T$ test cases follow.

For each test case, the first line contains 3 integers $n, m, Q$ ($2 \leq n \leq 10^5$, $1 \leq m \leq 2 \times 10^5$, $1 \leq Q \leq 2 \times 10^5$), which represent the number of cities, the number of roads, and the number of queries.

The next $m$ lines, each line contains three integers $x, y, k$ ($1 \leq x, y \leq n$, $1 \leq k \leq 10^9$), which represent the road connecting city $x$ and city $y$, and the strength of this road is $k$.

The next $Q$ lines, each line contains an integer $p_i$ ($1 \leq p_i \leq 10^9$), asking how many pairs of cities are reachable to each other if the enemy launches an attack with damage $p_i$.
 

Output
Output $\sum_{1}^{T} Q$ lines, each line contains an integer, representing the answer for each question.
 

Sample Input
1 5 5 3 1 2 2 2 3 3 3 4 1 4 5 1 5 1 3 3 2 1
 

Sample Output
2 6 10
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-04-24 17:19:17, Gzip enabled