#include "library.h"
#include<bits/stdc++.h>
#define vi vector<int>
#define vb vector<bool>
#define pb push_back
#define f0r(i,n) for(int i = 0; i<n; i++)
#define FOR(i, k, n) for(int i = k; i<n; i++)
using namespace std;
int n;
int solve(int prev, vi &v, int l, int r){
if(l == r){
return l;
}
int mid = (l + r)/2;
vi quer(n);
for(int i = l; i<=mid; i++){
quer[v[i]] = 1;
}
quer[prev] = 1;
int a1 = Query(quer);
quer[prev] = 0;
int a2 = Query(quer);
if(a1 == a2){
return solve(prev, v, l, mid);
}
else{
return solve(prev, v, mid+1, r);
}
}
void Solve(int n)
{
if(n == 1)Answer({1});
else{
::n = n;
int ret;
int st;
f0r(i, n){
vi quer(n);
f0r(j,n){
if(j != i)quer[i] = 1;
}
ret = Query(quer);
if(ret == 1){
st = i;
break;
}
}
vi ans(n);
ans[0] = st;
vb vis(n,0);
vis[st] = 1;
int prev = st;
FOR(i, 1, n){
vi cur;
f0r(j,n){
if(!vis[j])cur.pb(j);
}
int m = cur.size();
int nxt = solve(prev, cur, 0, m-1);
nxt = cur[nxt];
ans[i] = nxt;
prev = nxt;
vis[nxt] = 1;
}
f0r(i,n)ans[i]++;
Answer(ans);
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
49 ms |
348 KB |
Wrong Answer [8] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
49 ms |
348 KB |
Wrong Answer [8] |
2 |
Halted |
0 ms |
0 KB |
- |