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

建议使用的浏览器:

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

6350:Always Online

题目描述
Wayne is an administrator of some metropolitan area network. The network he managed can be formed into a simple connected graph with $n$ vertices and $m$ edges, which means the graph does not contain any self-loop and there is at most one edge and at least one path between every two vertices. Furthermore, the network also meets the condition there are at most two non-intersect paths, which share no common edges, between every two vertices.

Wayne knows the bandwidth of each edge in that network but it is not enough for him. He needs plenty of statistic data to display, for example, he wants to know what the maximum data rate between every two vertices is. For the sake of clarity, vertices in that are numbered from $1$ to $n$ and the maximum bits each edge could transmit per second will be given. Your task is assisting him to calculate the value of the following formula:

$$\sum_{1 \leq s < t \leq n}{\left(s \oplus t \oplus \mathrm{flow}(s, t)\right)},$$

where $\oplus$ means the bitwise exclusive-OR operator and $\mathrm{flow}(s, t)$ means the maximum bits that could be transmitted per second between vertex $s$ and vertex $t$.
输入解释
The first line contains one integer $T$, indicating the number of test cases.
The following lines describe all the test cases. For each test case:
The first line contains two integers $n$ and $m$.
Each of the following $m$ lines contains three integers $u, v$ and $w$, indicating a bidirectional edge between vertex $u$ and vertex $v$ that can transmit at most $w$ bits per second in each direction.
$1 \leq T \leq 100$, $1 \leq n \leq 10^5$, $n - 1 \leq m \leq \frac{3}{2}(n - 1)$, $1 \leq u, v \leq n$, $u \neq v$, $0 \leq w < 10^9$.
It is guaranteed that the sum of $n$ in all test cases does not exceed $10^6$ and the size of the standard input file does not exceed $26$ MiB.
输出解释
For each test case, print the answer in one line.
输入样例
2
3 3
1 2 5
2 3 6
3 1 5
5 6
1 2 5
2 3 6
3 1 5
3 4 6
4 5 5
5 3 6
输出样例
27
116

提示
For the first sample, flow(1, 2) = flow(1, 3) = 10, flow(2, 3) = 11.
来自杭电HDUOJ的附加信息
Recommend chendu

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

源链接: HDU-6350

最后修改于 2020-10-25T23:30:32+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
8000/4000MS(Java/Others) 262144/262144K(Java/Others)