This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
#include "prize.h"
int MAX,res=-1;
bool is_max(vector<int>x){
return x[0]+x[1]==MAX;
}
vector<vector<int>>v;
void divide(int l,int r){
if(l>r||res!=-1)return;
if(l==r){
if(v[l].size()==0)v[l]=ask(l);
if(v[l][0]+v[l][1]==0)res=l;
return;
}
int md=(l+r)>>1;
if(v[md].size()==0)v[md]=ask(md);
if(v[md]!=v[l-1])divide(l,md-1);
if(v[md]!=v[r+1])divide(md+1,r);
}
int find_best(int n){
v.clear();
v.resize(n);
MAX=0;
res=-1;
for(int i=0;i<min(n,500);i++){
vector<int>x=ask(i);
if(x[0]+x[1]==0)return i;
MAX=max(MAX,x[0]+x[1]);
}
v[0]=ask(0);
v[n-1]=ask(n-1);
divide(1,n-2);
return res;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |