Submission #316234

#TimeUsernameProblemLanguageResultExecution timeMemory
316234MrDominoThe Big Prize (IOI17_prize)C++14
20 / 100
112 ms6344 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]; set<int> s; int mx; int sol; int pos; int rn(int l, int r) { return l + rng() % (r - l + 1); } vector<int> get(int i) { if (ret[i].empty()) { ret[i] = ask(i); if (ret[i][0] == 0 && ret[i][1] == 0) { sol = i; } } if (ret[i][0] + ret[i][1] == mx) { s.insert(i); } return ret[i]; } bool is(int x) { return get(x)[0] + get(x)[1] == mx; } int rep(int l, int r) { if (l > r) { return 0; } auto it = s.lower_bound(r); if (it != s.end()) { auto it2 = s.lower_bound(l + 1); if (it2 != s.begin()) { it2--; int f = *it2; int s = *it; if (get(f)[0] == get(s)[0]) { return 0; } } } int m = (l + r) / 2; if (get(m)[0] == 0 && get(m)[1] == 0) { return m; } int x = rep(l, m - 1); if (x == 0) { x = rep(m + 1, r); } return x; } int find_best(int n) { sol = -1; vector<int> ord(n); for (int i = 0; i < n; i++) { ord[i] = i; } shuffle(ord.begin(), ord.end(), rng); while ((int) ord.size() > 100) { ord.pop_back(); } mx = 0; for (auto &x : ord) { mx = max(mx, get(x)[0] + get(x)[1]); } for (auto &x : ord) { if (is(x)) { s.insert(x); } } if (sol != -1) { return sol; } return rep(0, n - 1); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...