이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "prize.h"
#include<bits/stdc++.h>
using namespace std;
mt19937 rng(time(0));
int find_best(int n){
int ct=50,V=n;
while(ct--){
int x=rng()%n;
vector<int>tmp=ask(x);
if(n-(tmp[0]+tmp[1])<V) V=n-(tmp[0]+tmp[1]);
}
int res=-1;
set<int>st;
st.insert(-1),st.insert(n);
auto it=st.begin();
while(it!=st.end()){
int i=*it;
it++;
if(it==st.end()) break;
int j=*it;
int l=i+1,r=j-1;
while(l<=r){
int mid=(l+r)/2;
vector<int>tmp=ask(mid);
if(n-tmp[0]-tmp[1]!=V){
if(tmp[0]==0 && tmp[1]==0) {res=mid;break;}
st.insert(mid);
r=mid-1;
continue;
}
if(tmp[0]>=1) r=mid-1;
else l=mid+1;
}
}
/*for(int i = 0; i < n; i++) {
std::vector<int> res = ask(i);
if(res[0] + res[1] == 0)
return i;
}*/
return res;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |