12952022-03-30 16:32:35k_balintXorcpp14Wrong answer 10/10039ms8544 KiB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

void f(ll &x, ll a, ll b){
    for(ll i=a;i>=b;i--){
        x |= 1ll<<i;
    }
}

void solve(){
    ll l,r; cin>>l>>r;
    if(r-l<4){
        
        ll maxi=-1;
        ll x,y,z; x=y=z=0;
        for(ll i=l;i<r-1;i++){
            for(ll j=i+1;j<r;j++){
                for(ll k=j+1;k<=r;k++){
                    if((i^j^k)>maxi){
                        maxi=(i^j^k);
                        x=i; y=j; z=k;
                    }
                }
            }
        }
        cout << x << ' ' << y << ' ' << z << '\n';

        return;
    }

    ll frt=0;
    ll bit=62;
    while(((l>>bit) & 1) == ((r>>bit) & 1)){
        frt|=((l>>bit) & 1) << bit;
        --bit;
    }

    ll x,y,z; x=y=z=frt;

    ll bit2=bit-1;
    while( ((l>>bit2) & 1) && ((r>>bit2) & 1^1)){
        --bit2;
    }
    //cout << bit << ' ' <<bit2 << endl;

    if((l>>bit2) & 1){
        f(z,bit,bit);
        f(y,bit,bit);
        f(x,bit,bit);
        f(z,bit2,bit2);
        f(y,bit2-1,0);
    }
    else{
        f(z,bit,bit);
        f(y,bit-1,bit2+1);
        f(z,bit-1,bit2+1);
        f(y,bit2,bit2);
        f(x,bit2-1,0);
    }

    cout << x << ' ' << y << ' ' << z << '\n';
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int tc; cin>>tc;
    while(tc--){
        solve();
    }
}
SubtaskSumTestVerdictTimeMemory
base10/100
1Accepted0/02ms1892 KiB
2Wrong answer0/04ms2064 KiB
3Accepted5/51ms2036 KiB
4Wrong answer0/51ms2048 KiB
5Wrong answer0/51ms2052 KiB
6Accepted5/51ms2056 KiB
7Wrong answer0/52ms2088 KiB
8Wrong answer0/53ms2108 KiB
9Wrong answer0/54ms2208 KiB
10Wrong answer0/54ms2316 KiB
11Wrong answer0/58ms2544 KiB
12Wrong answer0/58ms2728 KiB
13Wrong answer0/517ms3088 KiB
14Wrong answer0/623ms3720 KiB
15Wrong answer0/630ms4540 KiB
16Wrong answer0/639ms5596 KiB
17Wrong answer0/639ms6648 KiB
18Wrong answer0/74ms6764 KiB
19Wrong answer0/739ms7792 KiB
20Wrong answer0/737ms8544 KiB