#include "bits/stdc++.h"
#include "library.h"
using namespace std;
#ifdef duc_debug
#include "bits/debug.h"
#else
#define debug(...)
#endif
const int maxn = 1005;
int N;
int Ask(vector<int> ask) {
vector<int> dark(N);
for(auto i:ask) {
dark[i - 1] = 1;
}
return Query(dark);
}
void Solve(int n) {
if(n == 1) {
Answer({1});
return;
}
N = n;
int outmost = 0;
for(int i = 1; i <= n; ++i) {
vector<int> t;
for(int j = 1; j <= n; ++j) {
if(i == j) continue;
t.push_back(j);
}
if(Ask(t) == 1) {
outmost = i;
break;
}
}
vector<int> res(1, outmost);
vector<bool> used(n + 1);
used[outmost] = 1;
int now = outmost;
for(int i = 2; i <= n; ++i) {
vector<int> rem;
for(int j = 1; j <= n; ++j) {
if(used[j]) continue;
rem.push_back(j);
}
int l = 0, r = (int)rem.size() - 1;
int cur = -1;
while(l <= r) {
int mid = (l + r) >> 1;
vector<int> hehe(rem.begin(), rem.begin() + mid + 1);
int x = Ask(hehe);
debug(hehe);
hehe.push_back(now);
int y = Ask(hehe);
if(x == y) {
cur = rem[mid];
r = mid - 1;
} else {
l = mid + 1;
}
}
res.push_back(cur);
used[cur] = 1;
now = cur;
}
// debug(res);
Answer(res);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |