#include "library.h"
#include <bits/stdc++.h>
//#include <cstdio>
//#include "grader.cpp"
using namespace std;
void Solve(int n) {
if(n == 1){
vector<int> res{1};
Answer(res);
return;
};
vector<int> us(n, 0), ans;
vector<int> org(n, 1);
int st = 0;
for(int i = 0; i < n; i ++ ) {
org[i] = 0;
int x = Query(org);
if(x == 1)st = i;
org[i] = 1;
}
ans.push_back(st);
us[st] = 1;
while(1){
vector<int> left;
for(int j = 0; j < n; j ++ ) {
if(!us[j]) left.push_back(j);
};
int t = 0;
int m = left.size();
if(!m)break;
for(int l = 0; l <= 10; l ++ ) {
vector<int> res(n, 0);
for(int j = 0; j < m; j ++ ) {
if(j >> l & 1) res[left[j]] = 1;
};
bool ok = 1;
for(int i : res) if(i) ok = 0;
if(ok)continue;
int x = Query(res);
res[ans.back()] = 1;
if(x == Query(res)){
t |= (1 << l);
};
};
ans.push_back(left[t]);
us[left[t]] = 1;
};
for(int &i : ans) i ++ ;
//for(int i : ans) cout << i << ' ';
//cout << '\n';
Answer(ans);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |