이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "prize.h"
#include <bits/stdc++.h>
using namespace std;
int find_best(int n) {
int cx = 0;
while (true) {
vector<int> X1 = ask(cx);
int L = cx, R = n, M, maxn = 0, QQ = 18;
vector<int> X2 = ask(min(n - 1, cx + 511));
if(X2 != X1) R = min(n, cx + 511);
else {
vector<int> X3 = ask(min(n - 1, cx + 2047));
if(X3 != X1) R = min(n, cx + 2047);
}
for (int i = 0; i <= 18; i++) { if ((1 << i) >= R - L + 1) { QQ = i; break; } }
for (int i = 0; i < QQ; i++) {
M = (L + R) / 2;
vector<int> R1 = ask(min(n, M));
if (R1[0] + R1[1] == 0) return M;
if (X1 == R1) { L = M; maxn = max(maxn, M); }
else { R = M; }
}
cx = maxn + 2;
}
return -1;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |