Submission #52717

#TimeUsernameProblemLanguageResultExecution timeMemory
52717KieranHorganThe Big Prize (IOI17_prize)C++17
0 / 100
47 ms5072 KiB
#include "prize.h" #include <bits/stdc++.h> using namespace std; vector<int> res[200000]; set<int> nextPos, curPos; vector<int> positions; int smaller, nextSmaller; int flag=-1; void get(int i) { if(res[i][0] != -1 && res[i][1] != -1) return; res[i] = ask(i); if(res[i][0]+res[i][1]==0) flag=i; } void dac(int lo, int hi) { // cerr << lo << " " << hi << endl; if(lo == hi) return; get(positions[lo]); if(flag!=-1) {return;} get(positions[hi]); if(flag!=-1) {return;} if(res[positions[lo]][0]==res[positions[hi]][0] && res[positions[lo]][1]==res[positions[hi]][1]) return; if(res[positions[lo]][1]-res[positions[hi]][1]==hi-lo-1) { for(int i = lo+1; i <= hi-1; i++) { nextPos.insert(positions[i]); get(positions[i]); if(flag!=-1) {return;} nextSmaller = max(nextSmaller, res[positions[i]][0]+res[positions[i]][1]); } return; } int mid = (hi+lo)/2; get(positions[mid]); if(flag!=-1) {return;} if(res[positions[mid]][0]+res[positions[mid]][1] == smaller) { dac(lo, mid); dac(mid, hi); return; } int m1 = mid; while(m1 != lo && res[positions[m1]][0]+res[positions[m1]][1] != smaller) { nextPos.insert(m1); nextSmaller = max(nextSmaller, res[positions[m1]][0]+res[positions[m1]][1]); m1--; get(positions[m1]); if(flag!=-1) {return;}} dac(lo, m1); int m2 = mid; while(m2 != hi && res[positions[m2]][0]+res[positions[m2]][1] != smaller) { nextPos.insert(m2); nextSmaller = max(nextSmaller, res[positions[m2]][0]+res[positions[m2]][1]); m2++; get(positions[m2]); if(flag!=-1) {return;}} dac(m2, hi); return; } int find_best(int n) { for(int i = 0; i < n; i++) { vector<int> res = ask(i); if(res[0] + res[1] == 0) return i; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...