Submission #316121

#TimeUsernameProblemLanguageResultExecution timeMemory
316121MrDominoThe Big Prize (IOI17_prize)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> ///#include "prize.h" using namespace std; mt19937 rng((long long) (new char)); const int N = 200000 + 7; vector<int> ret[N]; int sol = -1; /// delete vector<int> ask(int i) { cout << "? " << i << endl; vector<int> v(2); cin >> v[0] >> v[1]; return v; } vector<int> get(int i) { if (ret[i].empty()) { ret[i] = ask(i); if (ret[i][0] == 0 && ret[i][1] == 0) { sol = i; } } return ret[i]; } void after(int n, int pos) { get(pos); int cnt = 0, go = pos + 1; while (go < n) { int lo = go, hi = n - 1, id = -1; while (lo <= hi) { cout << "\t\t\t" << lo << " " << hi << "\n"; int mid = (lo + hi) / 2; if (get(mid)[0] + get(mid)[1] == get(pos)[0] + get(pos)[1]) { if (get(mid)[0] == get(pos)[0] + cnt) { lo = mid + 1; } else { id = mid; hi = mid - 1; } } else { id = mid; hi = mid - 1; } } if (id == -1) { break; } if (sol != -1) { return; } cnt++; go = id + 1; } } void before(int n, int pos) { get(pos); int cnt = 0, go = pos - 1; while (go >= 0) { int lo = 0, hi = go, id = -1; while (lo <= hi) { int mid = (lo + hi) / 2; if (get(mid)[0] + get(mid)[1] == get(pos)[0] + get(pos)[1]) { if (get(mid)[1] == get(pos)[1] + cnt) { hi = mid - 1; } else { id = mid; lo = mid + 1; } } else { id = mid; lo = mid + 1; } } if (id == -1) { break; } if (sol != -1) { return; } cnt++; go = id - 1; } } int find_best(int n) { int m = n / 2; int r1 = max(0, m - 250); int r2 = min(n - 1, m + 250); vector<int> ord; for (int j = r1; j <= r2; j++) { ord.push_back(j); } int big = 0, pos = -1; for (auto &i : ord) { big = max(big, get(i)[0] + get(i)[1]); } for (auto &i : ord) { if (big == get(i)[0] + get(i)[1]) { pos = i; } } assert(pos != -1); if (sol != -1) { return sol; } after(n, pos); if (sol != -1) { return sol; } before(n, pos); assert(sol != -1); return sol; } int main() { after(10, 0); cout << sol << "\n"; }

Compilation message (stderr)

/tmp/ccdROtwR.o: In function `ask(int)':
grader.cpp:(.text+0x0): multiple definition of `ask(int)'
/tmp/ccd5hrld.o:prize.cpp:(.text+0x30): first defined here
/tmp/ccdROtwR.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccd5hrld.o:prize.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status