当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

7123:City

题目描述
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$.
输入解释
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 $\sum_{1}^{T} Q$ lines, each line contains an integer, representing the answer for each question.
输入样例
1
5 5 3
1 2 2
2 3 3
3 4 1
4 5 1
5 1 3
3
2
1
输出样例
2
6
10

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-7123

最后修改于 2021-10-23T19:11:35+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
6000/3000MS(Java/Others) 65536/65536K(Java/Others)