The xor-longest Path(01字典树—求树上连续区间的最大异或值)

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

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:

_{xor}length(p)=\oplus_{e \in p}w(e)

⊕ 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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值