이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "prize.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> ans[200001];
map<int, set<int> > v;
int find_best(int n) {
queue<pair<int, int> > q;
q.push(make_pair(0, n - 1));
int l, r, m;
while(!q.empty()){
l = q.front().first;
r = q.front().second;
q.pop();
if(l > r){
continue;
}
m = (l + r) >> 1;
if(ans[m].size() == 0)ans[m] = ask(m);
if(ans[m][0] + ans[m][1] == 0){
return m;
}
v[ans[m][0] + ans[m][1]].insert(m);
auto it = v.find(ans[m][0] + ans[m][1]);
auto loc = it -> second.find(m);
bool in = 0;
auto tmp = loc;
while(tmp != it -> second.begin()){
if(ans[m][0] != ans[*tmp][0]){
in = 1;
tmp++;
q.push(make_pair(l, *tmp - 1));
break;
}
tmp--;
}
if(in == 0){
tmp = it->second.begin();
q.push(make_pair(l, *tmp - 1));
} else {
in = 0;
}
tmp = loc;
while(tmp != it -> second.end()){
if(ans[m][0] != ans[*tmp][0]){
in = 1;
tmp--;
q.push(make_pair(*tmp + 1, r));
break;
}
tmp++;
}
if(in == 0){
tmp = it->second.end();
tmp--;
q.push(make_pair(*tmp + 1, r));
}
}
}
컴파일 시 표준 에러 (stderr) 메시지
prize.cpp: In function 'int find_best(int)':
prize.cpp:59:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |