Submission #547580

#TimeUsernameProblemLanguageResultExecution timeMemory
547580MonarchuwuThe Big Prize (IOI17_prize)C++17
100 / 100
53 ms10716 KiB
#include "prize.h" #include<set> using namespace std; const int MAXN = 2e5 + 8; int ans; int prf[MAXN]; set<int> s[MAXN]; bool dnc(int l, int r) { if (l > r) return false; int m = (l + r) >> 1; vector<int> a = ask(m); int sum = a[0] + a[1]; prf[m] = a[0]; if (sum == 0) { ans = m; return true; } auto it = s[sum].insert(m).first; if (it == s[sum].begin() ? a[0] : prf[*prev(it)] != prf[m]) if (dnc(l, m - 1)) return true; if (next(it) == s[sum].end() ? a[1] : prf[m] != prf[*next(it)]) if (dnc(m + 1, r)) return true; return false; } int find_best(int N) { dnc(0, N - 1); return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...