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 "prize.h"
#include <bits/stdc++.h>
using namespace std;
int Rand(){
int G=0;
for(int i=0;i<30;i++){G+=(1<<i)*(rand()%2);}
return G;
}
int find_best(int n) {
int maxn=0;
for(int i=0;i<87;i++){
vector<int>p=ask(rand()%n);
maxn=max(maxn,p[0]+p[1]);
}
int cx=0;
for(int i=0;i<maxn;i++){
int L=cx, R = n + 1, M, res = cx - 1;
for(int j = 0; j < 20; j++) {
M = (L + R) / 2; int MM = min(M,n-1);
vector<int>p=ask(MM);
if(p[0]+p[1] == maxn && p[0] == i) { res = max(res, MM); L = MM + 1; }
else { R = MM; }
}
vector<int>p = ask(res+1);
if(p[0]==0 && p[1]==0) return res+1;
cx=res+2;
}
assert(false);
return -1;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |