#include <bits/stdc++.h>
using namespace std;
vector<int> res[200005];
int ans;
int big, nn;
vector<int> query(int i){
if(i == 0)
return vector<int>({0, big});
if(i == nn + 1)
return vector<int>({big, 0});
return ask(i - 1);
}
void find(int l, int r){
if(ans) return;
if(res[l][0] == res[r][0]) return;
int ll, rr, m = (l + r) >> 1;
res[m] = query(m);
if(res[m][0] + res[m][1] == big){
find(l, m);
find(m, r);
return;
}
if(res[m][0] + res[m][1] == 1){
ans = m;return;
}
for(rr = m + 1; rr < r; rr++){
res[rr] = query(rr);
if(res[rr][0] + res[rr][1] == big){
find(rr, r);
break;
}
if(res[rr][0] + res[rr][1] == 1){
ans = rr;
return;
}
}
for(ll = m - 1; ll > l; ll--){
res[ll] = query(ll);
if(res[ll][0] + res[ll][1] == big){
find(l, ll);
break;
}
if(res[ll][0] + res[ll][1] == 1){
ans = ll;
return;
}
}
}
int find_best(int n) {
nn = n;
for(int i = 0; i < 500; i++) {
vector<int> res = ask(i);
if(res[0] + res[1] == 0)
return i;
big = max(big, res[0] + res[1]);
}
res[0] = query(0);
res[nn + 1] = query(nn + 1);
find(0, nn + 1);
return ans - 1;
}
Compilation message
prize.cpp: In function 'std::vector<int> query(int)':
prize.cpp:13:11: error: 'ask' was not declared in this scope
return ask(i - 1);
^~~
prize.cpp: In function 'int find_best(int)':
prize.cpp:58:21: error: 'ask' was not declared in this scope
vector<int> res = ask(i);
^~~