이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |