close

Comments

F actually is far more easier than I thought,but it is hard for me still,the dp part is hard-thinking

My favorite editorial's style

but for beginners is a good chance to learn about the property of the diameter of a tree

that's why the contest call"abc" i guess

same feeling

potato

Has some one noticed that there are contradictory part of E2's explanation?

Or v must prevent Daiyousei from choosing this u.In other words, either wv≥wu, or u is within the subtree of v" but we know that u represent Daiyousei's choice and v represent Cirno's choice ,which means it is impossible for u is within the subtree of v

thank you sir for fast editorial

actually you dont't

#include<bits/stdc++.h>
using namespace std;


void solve(){
    int n;
    long long l, r;
    cin >> n >> l >> r;
    vector<int> a(n+1);
    for(int i=1;i<=n;i++) cin>>a[i];
    vector<int> pre(n+1);
    for(int i=1;i<=n;i++){
        pre[i]=pre[i-1]^a[i];
    }
    if(n%2==0){
        n++;
        a.push_back(pre[n/2]);
        pre.push_back(pre.back()^pre[n/2]);
    }
    
    int p=pre[n];
    function<int(long long)> get=[&](long long x)->int{
        if(x<=n) return a[(int)x];
        long long hf=x/2;
        if(hf<=n) return pre[hf];
        if(hf%2==0){
            return p^get(hf);
        }
        else return p;

    };
    cout<<get(l)<<'\n';
   
}

int main(){
    int t;
    cin >> t;
    while (t--) solve();
    system("pause");
    return 0;
}
void inc(int pos, int d) {
    for (; pos < n; pos |= pos + 1)
        f[pos] += d;
}