Submission #775756

#TimeUsernameProblemLanguageResultExecution timeMemory
775756APROHACKThe Big Prize (IOI17_prize)C++14
20 / 100
52 ms436 KiB
#include "prize.h" #include <bits/stdc++.h> #define ll long long #define pb push_back #define ff first #define ss second using namespace std; int sumMax = 0; bool confirm(vector<int>&t){ return t[0] + t[1] == 0; } int suma(vector<int>&t){return t[0] + t[1];} int find_best(int n) { vector<int>t; for(int i = 0 ; i < 500 ; i ++){ t = ask(i); sumMax = max(sumMax, suma(t)); if(confirm(t))return i; } queue<pair<int, int> >cola; cola.push({500, n-1}); while(!cola.empty()){ pair<int, int> cur = cola.front(); cola.pop(); if(cur.ff > cur.ss)continue; if(cur.ff == cur.ss){ t = ask(cur.ff); if(confirm(t))return cur.ff; } int midd = (cur.ff + cur.ss)/2, toL, k; t = ask(midd); k = midd; toL = midd-1; bool thereIsR = true; while(suma(t) != sumMax){ if(confirm(t))return k; k++; if(k > cur.ss){ thereIsR = false; break; } t = ask(k); } if(t[1] > 0 and thereIsR and k+1 <= cur.ss){ cola.push({k+1, cur.ss}); } if(t[0] > 0 and toL >= cur.ff)cola.push({cur.ff, toL}); if(t[0] > 0 and toL >= cur.ff)cola.push({cur.ff, toL}); } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...