题目链接:https://nanti.jisuanke.com/t/39277
每条合法(异或为0)的路径的贡献为路径两端点数的乘积。
当点分治确定root后,需要求出以root为根的各节点的siz。
然后按照路径两端点是否在同一颗子树上进行合并。
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/hash_policy.hpp>
#define rep(i, a, b) for(int i = (a); i <= (b); i++)
#define pb push_back
#define ll long long
using namespace std;
using namespace __gnu_pbds;
const int N = 1e5+1000;
const int mod = 1e9+7;
int n,k;
struct node {
int v,nxt;
ll w;
}edge[2*N];
int tot,head[N];
void ae(int u,int v,ll w) {
edge[++tot] = node{v,head[u],w};
head[u] = tot;
}
void init(int n) {
tot = 0;
rep(i, 1, n) head[i] = -1;
}
int siz[N],Root,wt[N],Tsiz,fa[N],siz1[N];
bool vis[N];
ll ans;
gp_hash_table<ll,ll> num,Tnum;
void GetRoot(int u,int f,bool f