#include <bits/stdc++.h>
#include "library.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define pb push_back
#define ff first
#define ss second
void Solve(int n){
int f = 1;
vector<int> used(n, 1);
for (int i = 2; i <= n; i++){
used[i - 1] = 0;
if (Query(used) == 1){
f = i;
break;
}
used[i - 1] = 1;
}
vector<int> out = {f}, all;
for (int i = 1; i <= n; i++){
all.pb(i);
}
all.erase(find(all.begin(), all.end(), f));
int tt = n - 1;
while (tt--){
int l = 0, r = (int) all.size() - 1;
auto check = [&](int m){
fill(used.begin(), used.end(), 0);
for (int i = 0; i <= m; i++){
used[all[i] - 1] = 1;
}
int x = Query(used);
used[f - 1] = 1;
int y = Query(used);
return (x == y);
};
while (l + 1 < r){
int m = (l + r) / 2;
if (check(m)){
r = m;
}
else {
l = m + 1;
}
}
if (check(l)) r = l;
f = all[r]; out.pb(f);
all.erase(all.begin() + r);
}
Answer(out);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |