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;
vector<int>vec;
int find_best(int n) {
// -------------- 前処理 -----------------
for(int i=0;i<n;i++) vec.push_back(i);
while(vec.size() >= 2){
int maxn=0;
for(int i=0;i<30;i++){
vector<int>P = ask(vec[rand()%vec.size()]);
maxn = max(maxn, P[0] + P[1]);
}
assert(maxn<(int)vec.size());
vector<int>vec2; int ret = -1;
for(int h=0;h<maxn;h++){
int cx = 0;
for(int i=17;i>=0;i--){
int pos = cx + (1 << i) - 1; if(pos >= (int)vec.size()) pos = vec.size() - 1;
vector<int>L = ask(vec[pos]);
if((L[0] + L[1] == maxn && L[0] == h) || pos <= ret) cx += (1 << i);
}
assert(cx==262143);
vec2.push_back(vec[cx]); ret = cx;
}
vec = vec2;
}
return vec[0];
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |