那你一定是在询问(u,v)的最大值时写下了如下代码
int query(int l,int r,int x){
int u = head2[l - 1], v = head2[r], ans = 0;
for(int i = 31;i + 1;i--){
bool opt = (x >> i) & 1;
if(cnt2[trie2[v][!opt]] - cnt2[trie2[u][!opt]] > 0){opt = !opt;ans += (1 << i);}
u = trie2[u][opt]; v = trie2[v][opt];
}
return ans;
}
其中第二行的head2[l−1]显然是错的,因为树上的查询是[lca,v]==(falca,v]而不是简单的lca−1我不会告诉你因为这个调了好久的