166972025-05-09 15:46:08algoproXorcpp17Wrong answer 0/10048ms1328 KiB
// UUID: 53ff18bb-e62c-4686-b39b-33648e4b2438
#include <bits/stdc++.h>
using namespace std;
using ll=long long;

#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define vi vector<int>
#define pii pair<int,int>

const int maxbit=63;

pair<ll, ll> get(ll a, ll b){
    pair<ll,ll> res={0, 0};
    int bit=maxbit;
    while (bit>=0){
        if (a>>bit == b>>bit){
            res.first+=(a&(a<<bit));
            res.second+=(b&(b<<bit));
        }
        else break;
        bit--;
    }
    if (bit<0) return res;
    res.first+=(1<<bit)-1;
    res.second+=(1<<bit);
    return res;
}

void solve(){
    ll l,r;
    cin>>l>>r;
    ll base=0;
    int bit=maxbit;
    while (bit>=0){
        if (l>>bit==r>>bit){
            base+=(l&(l<<bit));
        }
        else break;
        bit--;
    }
    ll x = 1<<bit;
    x+=base;
    
    auto [y1,z1] = get(x+1, r);
    auto [y2,z2] = get(l, x-1);
    if (r-l==2){
        cout<<l<<" "<<l+1<<" "<<r<<"\n";
        return;
    }

    if (r-(x+1)<1 || x^y1^z1<x^y2^z2){
        cout<<y2<<" "<<z2<<" "<<x<<"\n";
        return;
    } 

    cout<<x<<" "<<y1<<" "<<z1<<"\n";
    return;
}

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    int t=1;
    cin>>t;
    while (t--){
        solve();
    }
}
SubtaskSumTestVerdictTimeMemory
base0/100
1Accepted0/01ms316 KiB
2Wrong answer0/06ms316 KiB
3Wrong answer0/51ms500 KiB
4Wrong answer0/51ms316 KiB
5Wrong answer0/51ms316 KiB
6Wrong answer0/51ms316 KiB
7Wrong answer0/53ms316 KiB
8Wrong answer0/54ms468 KiB
9Wrong answer0/54ms316 KiB
10Wrong answer0/56ms436 KiB
11Wrong answer0/510ms564 KiB
12Wrong answer0/510ms592 KiB
13Wrong answer0/519ms632 KiB
14Wrong answer0/628ms868 KiB
15Wrong answer0/639ms1080 KiB
16Wrong answer0/648ms1152 KiB
17Wrong answer0/648ms1328 KiB
18Wrong answer0/76ms508 KiB
19Wrong answer0/748ms1184 KiB
20Wrong answer0/748ms1328 KiB