#include <bits/stdc++.h>
#include "library.h"
using namespace std;
void Solve(int n) {
int f = 0;
vector<int> a(n, 1);
if (n == 1) {
Answer(a);
return;
}
for (int i = 0; i < n; ++i) {
a[i] = 0;
if (Query(a) == 1) {
f = i+1;
break;
}
a[i] = 1;
}
vector<int> ans = {f};
for (int i = 1; i < n; ++i) {
vector<int> S(n, 1);
for (auto x : ans) S[x-1] = 0;
while (1) {
vector<int> S1(n, 0), S2(n, 0);
int C = 0, t = 0, sz = 0;
for (int j = 0; j < n; ++j) sz += S[j];
for (int j = 0; j < n; ++j) {
if (S[j]) {
if (C < (sz+1)/2) S1[j] = 1, t = j+1;
else {
S2[j] = 1;
}
++C;
}
}
if (C == 1) {
ans.push_back(t);
break;
}
int x = Query(S1);
S1[ans.back() - 1] = 1;
if (Query(S1) > x) S = S2;
else {
S1[ans.back() - 1] = 0;
S = S1;
}
}
}
Answer(ans);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |