The xor-longest Path
| Time Limit: 2000MS | Memory Limit: 65536K | |
| Total Submissions: 10003 | Accepted: 2029 |
Description
In an edge-weighted tree, the xor-length of a path p is defined as the xor sum of the weights of edges on p:

⊕ is the xor operator.
We say a path the xor-longest path if it has the largest xor-length. Given an edge-weighted tree with n nodes, can you find the xor-longest path?
Input
The input contains several test cases. The first line of each test case contains an integer n(1<=n<=100000), The following

给定一棵加权树,异或长度定义为路径上边权重的异或和。任务是找到异或长度最大的路径。输入包含多组测试案例,描述树的节点数和边的信息。输出异或最长路径的异或长度。解题思路是预处理各节点到根的异或值,并使用字典树存储,然后每节点寻找使得异或值最大的路径,复杂度为N*LOGN。
最低0.47元/天 解锁文章
9万+

被折叠的 条评论
为什么被折叠?



