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 <bits/stdc++.h>
#include "library.h"
using namespace std;
void Solve(int N)
{
vector<int> vec(N), res(N);
for (int i = 0, pre; i < N; ++i) {
int l = 0, r = N - 1;
while (l < r) {
int m = l + r >> 1;
int t, a, b;
vector<int> v = vec;
fill(v.begin() + l, v.begin() + m + 1, 1);
a = Query(v);
if (i == 0) {
for (auto &j: v) j ^= 1;
if (accumulate(v.begin(), v.end(), 0)) b = Query(v);
else b = 0;
t = a >= b;
}
else {
v[pre] = 0;
if (accumulate(v.begin(), v.end(), 0)) b = Query(v);
else b = 0;
if (i == 1) t = a == b;
else t = a < b;
}
if (t) r = m;
else l = m + 1;
}
vec[l] = 1;
pre = l;
res[i] = l + 1;
}
Answer(res);
}
Compilation message (stderr)
library.cpp: In function 'void Solve(int)':
library.cpp:11:14: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
int m = l + r >> 1;
~~^~~
library.cpp:23:10: warning: 'pre' may be used uninitialized in this function [-Wmaybe-uninitialized]
v[pre] = 0;
^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |