12962022-03-30 17:03:13k_balintXorcpp14Accepted 100/10039ms8852 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;
    }

    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(x,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
base100/100
1Accepted0/02ms1820 KiB
2Accepted0/08ms2052 KiB
3Accepted5/51ms2020 KiB
4Accepted5/51ms2048 KiB
5Accepted5/51ms2052 KiB
6Accepted5/51ms2064 KiB
7Accepted5/52ms2088 KiB
8Accepted5/53ms2116 KiB
9Accepted5/54ms2264 KiB
10Accepted5/54ms2292 KiB
11Accepted5/58ms2496 KiB
12Accepted5/58ms2728 KiB
13Accepted5/516ms3112 KiB
14Accepted6/623ms3720 KiB
15Accepted6/629ms4532 KiB
16Accepted6/637ms5580 KiB
17Accepted6/639ms6632 KiB
18Accepted7/74ms6756 KiB
19Accepted7/739ms7816 KiB
20Accepted7/739ms8852 KiB