Comments

Could someone tell me what is wrong with my submission https://mirror.codeforces.com/contest/1968/submission/259550793

Binary Search on Prefiquence felt more intuitive. https://mirror.codeforces.com/contest/1968/submission/259543727

Thank you, your explanation is crystal clear. I completely trolled this.

I'm sorry what I meant is I got all these observations in contest but could you specifically explain your code here.

fors(i,1,n){
        int msb=0;
        fors(bit,0,31){
            if((a[i-1]&(1<<bit))!=0){
                msb=bit;
            }
        }
        int ro,re,lo,le;
        int val=right[msb][n]-right[msb][i];
        if(right[msb][i]!=right[msb][i-1]){
            re=val+1;
            ro=n-i-val;
        }
        else{
            ro=val;
            re=n-i-val+1;
        }
        val=left[msb][0]-left[msb][i-1];
        if(left[msb][i-1]!=left[msb][i]){
            le=val+1;
            lo=i-1-val;
        }
        else{
            lo=val;
            le=i-val;
        }
        ans+=lo*re+le*ro;
    }

me too, could someone detail their intuition behind their sol

Could someone send me some problems like D please.

too easy