Submission #1037213

#TimeUsernameProblemLanguageResultExecution timeMemory
1037213beaconmcČVENK (COI15_cvenk)C++14
0 / 100
0 ms448 KiB
#include <bits/stdc++.h> typedef int ll; #define FOR(i,x,y) for(ll i=x; i<y; i++) #define FORNEG(i,x,y) for(ll i=x; i>y; i--) using namespace std; vector<ll> lca(vector<ll> a, vector<ll> b){ if (a[0]+a[1] < b[0] + b[1]) swap(a,b); set<vector<ll>> stuff; stuff.insert(a); FOR(i,0,30){ if ((1<<i) & a[0]){ a[0] -= (1<<i); stuff.insert(a); } if ((1<<i) & a[1]){ a[1] -= (1<<i); stuff.insert(a); } } FOR(i,0,30){ if ((1<<i) & b[0]){ if (stuff.count({b[0]-(1<<i), b[1]})) return b; b[0] -= (1<<i); } if ((1<<i) & b[1]){ if (stuff.count({b[0], b[1]-(1<<i)})) return b; b[1] -= (1<<i); } } return {}; } int main(){ ll n; cin >> n; vector<ll> A(2); vector<ll> B(2); cin >> A[0] >> A[1] >> B[0] >> B[1]; vector<ll> sus = lca(A,B); cout << A[0]+A[1]+B[0]+B[1]-sus[0]*2-sus[1]*2; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...