Submission #55485

#TimeUsernameProblemLanguageResultExecution timeMemory
55485minkankThe Big Prize (IOI17_prize)C++17
100 / 100
66 ms956 KiB
#include <bits/stdc++.h> #include "prize.h" using namespace std; typedef pair<int, int> ii; #define x first #define y second int res; map<int, map<int, ii> > p; void solve(int l, int r) { if(res != -1 || l > r) return; int mid = (l + r) / 2; vector<int> tmp = ask(mid); ii val = ii(tmp[0], tmp[1]); if(val.x == 0 && val.y == 0) { res = mid; return; } bool canL = 1, canR = 1; auto nxt = p[val.x + val.y].lower_bound(mid); if(nxt != p[val.x + val.y].begin()) { nxt--; if((*nxt).y.x == val.x) canL = 0; nxt++; } if(nxt != p[val.x + val.y].end()) { if((*nxt).y.y == val.y) canR = 0; } p[val.x + val.y][mid] = val; if(canL) solve(l, mid - 1); if(canR) solve(mid + 1, r); } int find_best(int n) { res = -1; p.clear(); solve(0, n - 1); return res; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...