이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include"prize.h"
#include<bits/stdc++.h>
using namespace std;
int ans = -1;
bool check(vector<int> res) {
return (res[0] == res[1] && res[0] == 0);
}
vector<vector<int>> seg(200005, {-1, -1});
void calc(int l, int r) {
if (l == r || ans != -1) {
return;
}
int m = (l+r)/2;
if (seg[m+1][0] == -1) {
seg[m+1] = ask(m+1);
}
if (check(seg[m+1])) {
ans = m+1;
return;
}
if (seg[r][0] == -1) {
seg[r] = ask(r);
}
if (check(seg[r])) {
ans = r;
return;
}
if (seg[m+1] != seg[r]) {
calc(m+1, r);
}
if (ans != -1) {
return;
}
if (seg[l][0] == -1) {
seg[l] = ask(l);
}
if (check(seg[l])) {
ans = l;
return;
}
if (seg[m][0] == -1) {
seg[m] = ask(m);
}
if (check(seg[m])) {
ans = m;
return;
}
if (seg[l] != seg[m]) {
calc(l, m);
}
}
int find_best(int n) {
calc(0, n-1);
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |