# bzoj1954 The xor-longest path

## Description

给定一棵n个点的带权树，求树上最长的异或和路径

## Input

The input contains several test cases. The first line of each test case contains an integer n(1<=n<=100000), The following n-1 lines each contains three integers u(0 <= u < n),v(0 <= v < n),w(0 <= w < 2^31), which means there is an edge between node u and v of length w.

## Output

For each test case output the xor-length of the xor-longest path.

4
1 2 3
2 3 4
2 4 6

7

## HINT

The xor-longest path is 1->2->3, which has length 7 (=3 ⊕ 4)

#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
#define REP(i,k,n) for(int i=k;i<=n;i++)
#define MAXN 300010
using namespace std;
int x=0,f=1;
char ch=getchar();
for(;!isdigit(ch);ch=getchar())
if(ch=='-')
f=-1;
for(;isdigit(ch);ch=getchar())
x=x*10+ch-'0';
return x*f;
}
queue <int> Q;
int n,cnt=0,ans;
int vis[MAXN],sum[MAXN];
int tree[6333333][2];
inline void adl(int a,int b,int c){
total++;
to[total]=b;
val[total]=c;
return ;
}
inline void bfs(){
Q.push(1);
vis[1]=1;
while(!Q.empty()){
int u=Q.front();
Q.pop();
if(!vis[to[e]]){
vis[to[e]]=1;
sum[to[e]]=sum[u]^val[e];
Q.push(to[e]);
}
}
return ;
}
inline void insert(int x){
int u=0;
for(int i=30;i>=0;i--){
int t=x&(1<<i);
t=(t>>i);
if(!tree[u][t])  tree[u][t]=++cnt;
u=tree[u][t];
}
return ;
}
inline int query(int x){
int u=0,tmp=0;
for(int i=30;i>=0;i--){
int t=x&(1<<i);
t=(t>>i);
if(tree[u][t^1])  u=tree[u][t^1],tmp+=(1<<i);
else  u=tree[u][t];
}
return tmp;
}
int main(){
in(n);
int a,b,c;
}