Submission #524850

#TimeUsernameProblemLanguageResultExecution timeMemory
524850EvirirThe Big Prize (IOI17_prize)C++17
20 / 100
52 ms5208 KiB
#include "prize.h" #include <bits/stdc++.h> using namespace std; int num = 0; #define sz(a) (int)(a.size()); vector<int>res[200000]; int cnt = 0; int solve(int l,int r,int lf = 0,int rg = 0){ if(l > r)return -1; int mid = (l+r)/2; for(int i=0;i<=r-l;i++){ int ml = mid-i/2; int mr = mid+(i+1)/2; int m = i%2==0?ml : mr; int tmpl = i%2==0?0:mr-ml; int tmpr = i%2==1?0:mr-ml; res[m] = ask(m); if(!res[m][0] && !res[m][1])return m; if(res[m][0] + res[m][1] == num){ int c = -1; if(res[m][0]-tmpl>lf)c = max(c,solve(l,ml-1,lf,res[m][1]+tmpl)); if(res[m][1]-tmpr>rg)c = max(c,solve(mr+1,r,res[m][0]+tmpr,rg)); return c; } } return -1; } mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); int find_best(int n) { for(int i=0;i<200;i++){ //random until find dao biggest guy int c = uniform_int_distribution<int>(0,n-1)(rng); vector<int>res = ask(c); num = max(num,res[0]+res[1]); if(!res[0] && !res[1])return c; } //d&c to try all small guys since < #small guys < sqrt(n) return solve(0,n-1); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...