Untitled

mail@pastecode.io avatar
unknown
plain_text
15 days ago
927 B
1
Indexable
Never
#pragma GCC optimize("O2,no-stack-protector,unroll-loops")
#define ll long long
#define pb push_back
#define ipar(arr, n) vector<ll> arr(n); for(int i=0;i<n;i++) cin>>arr[i];
#include <cmath>
#include <bits/stdc++.h>
#define pii pair<int, int>;
#define pll pair<ll, ll>;
using namespace std;


void solve(){
    ll a,b,c; cin>>a>>b>>c;
    ll ans=0;
    for(int i=29;i>=0;i--){
        ll x=(1<<i)^a;
        ll y=(1<<i)^b;
        ll z=(1<<i)^c;
        if(x<y && y<z){ //both job done
            ans^=(1<<i);
            a=x;
            b=y;
            c=z;
            break;
        }else
        if(x<min(y,z) || max(x,y)<z){//half job done
            ans^=(1<<i);
            a=x;
            b=y;
            c=z;
        }
    }
    if(a<b && b<c) cout<<ans<<"\n";
    else cout<<-1<<"\n";
}


signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int t;
	cin>>t;
	while(t--) solve();
}
Leave a Comment