#include <cstdio>
#include <vector>
#include "library.h"
using namespace std;
void Solve(int N) {
vector<int> M(N, 1);
int st = 0;
vector<int> res;
vector<int> in(N);
for (int i = 0; i < N; ++i) {
M[i] = 0;
if (Query(M) == 1) {
res.push_back(i);
st = i;
in[st] = 1;
break;
}
M[i] = 1;
}
auto make = [&](vector<int> v) {
vector<int> ret(N);
for (int i : v) {
ret[i] = 1;
}
return ret;
};
for (int i = 1; i < N; ++i) {// == res.size() < n
vector<int> available;
for (int j = 0; j < N; ++j) {
if (!in[j] && j != i) {
available.push_back(j);
}
}
while (available.size() > 1) {
vector<int> ask;
for (int j = 0; j < (int) available.size() / 2; ++j) {
ask.push_back(available[j]);
}
int x = Query(make(ask));
ask.push_back(st);
int y = Query(make(ask));
ask.pop_back();
if (x != y) {
ask.clear();
for (int j = (int) available.size() / 2; j < (int) available.size(); ++j) {
ask.push_back(available[j]);
}
}
available = ask;
}
res.push_back(available[0]);
in[res.back()] = true;
st = res.back();
}
for (int i = 0; i < N; ++i) {
res[i]++;
}
Answer(res);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
19 ms |
440 KB |
Wrong Answer [8] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
19 ms |
440 KB |
Wrong Answer [8] |
2 |
Halted |
0 ms |
0 KB |
- |