# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
60980 | kingpig9 | Cup of Jamshid (IOI17_cup) | C++11 | 4 ms | 376 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#include "cup.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define fi first
#define se second
#define all(v) (v).begin(), (v).end()
#define fillchar(a, s) memset((a), (s), sizeof(a))
bool isdesert (int x) {
return abs(x) <= 5e8;
}
bool isdesert (int x, int y) {
return isdesert(x) && isdesert(y);
}
pii _find_cup() {
//find the x value first
int dbase = ask_shahrasb(5e8, 5e8);
int dx = 0;
for (int i = 0; i <= 28; i++) {
int di = ask_shahrasb(5e8 + (1 << i), 5e8) ^ dbase;
di = ((di >> i) + 1) / 2;
assert((di & (di - 1)) == 0);
if (di != 1) {
dx ^= (1 << i);
}
}
//hmm we need to find the 2^29 digit in a special way.
//this is the most annoying part...
int x[2] = {int(5e8) - dx, int(5e8) - (dx ^ (1 << 29))};
int dy = dbase ^ dx;
int y[2] = {int(5e8) - dy, int(5e8) - (dy ^ (1 << 29))};
vector<pii> poss;
for (int i = 0; i < 2; i++) {
if (!isdesert(x[i])) {
continue;
}
for (int j = 0; j < 2; j++) {
if (!isdesert(y[j])) {
continue;
}
if (dbase != ((int(5e8) - x[i]) ^ (int(5e8) - y[j]))) {
continue;
}
poss.push_back({x[i], y[j]});
//return vector<int> {x[i], y[i]};
}
}
//ok which of them is actually the one?
if (poss.size() == 1) {
return pii(poss[0].fi, poss[0].se);
}
assert(poss.size() == 2);
sort(all(poss));
if (poss[0].se < poss[1].se) {
if (ask_shahrasb(poss[0].fi + 2, poss[0].se + 1) == 3) {
return poss[0];
}
return poss[1];
} else {
if (ask_shahrasb(poss[0].fi + 2, poss[0].se - 1) == 3) {
return poss[0];
} else {
return poss[1];
}
}
}
vector<int> find_cup() {
pii p = _find_cup();
return vector<int> {p.fi, p.se};
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |