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> a(n);
for(int i = 0; i < n; i++) {
a[i] = 1;
}
int px = -1;
for (int i = 0; i < n; i++) {
a[i] = 0;
if (Query(a) == 1) {
px = i + 1;
}
a[i] = 1;
}
vector<int> res(n);
res[0] = px;
vector<int> p(n);
iota(p.begin(), p.end(), 1);
p.erase(find(p.begin(), p.end(), px));
for (int i = 1; i < n; i++) {
int lt = 0;
int rt = (int)p.size() - 1;
int pt = -1;
while (lt <= rt) {
int mt = (lt + rt) / 2;
fill(a.begin(), a.end(), 0);
for (int j = 0; j <= mt; j++) {
a[p[j] - 1] = 1;
}
int d1 = Query(a);
a[px - 1] = 1;
int d2 = Query(a);
if (d1 == d2) {
pt = mt;
rt = mt - 1;
}
else {
lt = mt + 1;
}
}
res[i] = (px = p[pt]);
p.erase(find(p.begin(), p.end(), px));
}
Answer(res);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |