이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define ii pair<ll, ll>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define F0R(i, n) for (int i = 0; i < n; i++)
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define inf 1000000010
void clean(ii &a, ii &b) {
for (int i = 30; ~i; i--) {
if ((a.f & (1 << i)) && (b.f & (1 << i))) {
a.f ^= (1 << i);
b.f ^= (1 << i);
} else if ((a.s & (1 << i)) && (b.s & (1 << i))) {
a.s ^= (1 << i);
b.s ^= (1 << i);
} else if ((a.f & (1 << i)) || (b.f & (1 << i)) || (a.s & (1 << i)) || (b.s & (1 << i))) {
break;
}
}
}
bool isLeft(ii x) {
for (int i = 30; ~i; i--) {
if (x.f & (1 << i)) {
return true;
} else if (x.s & (1 << i)) {
return false;
}
}
return false;
}
int main() {
cin.tie(0)->sync_with_stdio(0);
int n; cin >> n; assert(n == 2);
ii a, b; cin >> a.f >> a.s >> b.f >> b.s;
clean(a, b);
//cout << a.f << " "<< a.s << " " << b.f << " " << b.s << endl;
if (isLeft(a) == isLeft(b)) {
if (isLeft(a)) {
cout << a.f + a.s + b.f + b.s - 2*min(a.f, b.f) << endl;
} else {
cout << a.f + a.s + b.f + b.s - 2*min(a.s, b.s) << endl;
}
} else {
cout << a.f + a.s + b.f + b.s << endl;
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |