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

建议使用的浏览器:

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

2832:How Many Pairs?

题目描述

You are given an undirected graph G with N vertices and M edges. Each edge has a length. Below are two definitions.

  1. Define max_len(p) as the length of the edge with the maximum length of p where p is an arbitrary non-empty path in G.
  2. Define min_pair(u, v) as min{max_len(p) | p is a path connecting the vertices u and v.}. If there is no paths connecting u and v, min_pair(u, v) is defined as infinity.

Your task is to count the number of (unordered) pairs of vertices u and v satisfying the condition that min_pair(u, v) is not greater than a given integer A.

输入解释

The first line of input contains three integer N, M and Q (1 < N ≤ 10,000, 0 < M ≤ 50,000, 0 < Q ≤ 10,000). N is the number of vertices, M is the number of edges and Q is the number of queries. Each of the next M lines contains three integers a, b, and c (1 ≤ a, bN, 0 ≤ c < 108) describing an edge connecting the vertices a and b with length c. Each of the following Q lines gives a query consisting of a single integer A (0 ≤ A < 108).

输出解释

Output the answer to each query on a separate line.

输入样例
4 5 4
1 2 1
2 3 2
2 3 5
3 4 3
4 1 4
0
1
3
2
输出样例
0
1
6
3
来自北京大学POJ的附加信息
Case time limit(单组数据时间限制) 1000MS

该题目是Virtual Judge题目,来自 北京大学POJ

源链接: POJ-2832

最后修改于 2020-10-29T06:45:21+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
3000 65536