This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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> G = {250, 1000, 4000, 16000};
for (int i = 0; i < G.size(); i++) {
vector<int> X2 = ask(min(n - 1, cx + G[i]));
if (X2 != X1) { R = min(n, cx + G[i]); break; }
}
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; bool flag = false; if (R - L <= 1) flag = true;
vector<int> R1 = ask(min(n, M));
if (R1[0] + R1[1] == 0) return M;
if (X1 == R1) { L = M + 1; maxn = max(maxn, M); }
else { R = M; }
if (flag == true) break;
}
cx = maxn + 2;
}
return -1;
}
Compilation message (stderr)
prize.cpp: In function 'int find_best(int)':
prize.cpp:14:25: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 0; i < G.size(); i++) {
~~^~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |