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

建议使用的浏览器:

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

5544:Ba Gua Zhen

题目描述
During the Three-Kingdom period, there was a general named Xun Lu who belonged to Kingdom Wu. Once his troop were chasing Bei Liu, he was stuck in the Ba Gua Zhen from Liang Zhuge. The puzzle could be considered as an undirected graph with $N$ vertexes and $M$ edges. Each edge in the puzzle connected two vertexes which were $u_{i}$ and $v_{i}$ with a length of wi. Liang Zhuge had great interests in the beauty of his puzzle, so there were no self-loops and between each pair of vertexes, there would be at most one edge in the puzzle. And it was also guaranteed that there was at least one path to go between each pair of vertexes.

Fortunately, there was an old man named Chengyan Huang who was willing to help Xun Lu to hack the puzzle. Chengyan told Xun Lu that he had to choose a vertex as the start point, then walk through some of the edges and return to the start point at last. During his walk, he could go through some edges any times. Since Liang Zhuge had some mysterious magic, Xun Lu could hack the puzzle if and only if he could find such a path with the maximum XOR sum of all the edges length he has passed. If the he passed some edge multiple times, the length would also be calculated by multiple times. Now, could you tell Xun Lu which is the maximum XOR circuit path in this puzzle to help him hack the puzzle?
输入解释
The first line of the input gives the number of test cases, $T(1≤T≤30)$. $T$ test cases follow.

Each test case begins with two integers $N(2≤N≤5×10^4)$ and $M(1≤M≤10^5)$ in one line. Then $M$ lines follow. Each line contains three integers $u_{i}$, $v_{i}$ and $w_{i}(1≤u_{i},v_{i}≤N, 0≤w_{i}≤2^{60}-1)$ to describe all the edges in the puzzle.
输出解释
For each test case, output one line containing Case #x: y, where $x$ is the test case number (starting from 1) and $y$ is the maximum XOR sum of one circuit path in the puzzle.
输入样例
2
3 3
1 2 1
1 3 2
2 3 0
6 7
1 2 1
1 3 1
2 3 1
3 4 4
4 5 2
4 6 2
5 6 2
输出样例
Case #1: 3
Case #2: 3
提示
A XOR takes two bit patterns of equal length and performs the logical exclusive OR operation on each pair of corresponding bits. 
The result in each position is 1 if only the first bit is 1 or only the second bit is 1, but will be 0 if both are 0 or both are 1. 
In this we perform the comparison of two bits, being 1 if the two bits are different, and 0 if they are the same.
来自杭电HDUOJ的附加信息
Recommend wange2014

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

源链接: HDU-5544

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

共提交 0

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