이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "prize.h"
#include<bits/stdc++.h>
using namespace std;
const int N=(1<<19);
set<int> S;
vector<vector<int>> V;
vector<int> ask2(int i){
if(S.find(i)==S.end())V[i]=ask(i), S.insert(i);
return V[i];
}
int find_best(int n) {
V.resize(n);
map<int, int> M;
for(int i = 0; i < n; ) {
std::vector<int> res = ask2(i);
if(res==vector<int>{0, 0})return i;
auto it=S.lower_bound(i);
int l=0, r=n-i-1;
while(V[*it]==res){
l=*it-i;
it++;
}
if(it!=S.end())r=*it-i;
if(M[res[0]+res[1]]++>100){
while(l<r){
int m;
m=(l+r+1)/2;
vector<int> res2=ask2(i+m);
if(res2==res)l=m;
else r=m-1;
}
M[res[0]+res[1]]+=l;
}
i+=l+1;
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |