#include "library.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
int n;
int qry(vector <int> p){
vector <int> M(n);
for ( auto &x: p ) M[x] = 1;
return Query(M);
}
void Solve(int N){
n = N;
int st = -1;
vector <int> M(n, 1), res(n);
for ( int i = 0; i < n; i++ ){
M[i] = 0;
if ( Query(M) == 1 ){
st = i; break;
} M[i] = 1;
}
vector <int> chk(n);
res[0] = st; chk[st] = 1;
for ( int i = 1; i < n; i++ ){
vector <int> q;
for ( int j = 0; j < n; j++ ){
if ( !chk[j] ) q.pb(j);
}
int u = 0, m = q.size();
for ( int lg = 0; lg <= 10; lg++ ){
vector <int> t;
for ( int j = 0; j < m; j++ ){
if ( j >> lg & 1 ) t.pb(q[j]);
}
if ( t.empty() ) continue;
int w = qry(t); t.pb(res[i - 1]);
if ( w == qry(t) ){
u |= 1 << lg;
}
}
res[i] = q[u]; chk[q[u]] = 1;
}
for ( auto &x: res ) x++;
Answer(res);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
17 ms |
344 KB |
# of queries: 2563 |
2 |
Correct |
21 ms |
344 KB |
# of queries: 2599 |
3 |
Correct |
28 ms |
344 KB |
# of queries: 2816 |
4 |
Correct |
24 ms |
344 KB |
# of queries: 2765 |
5 |
Correct |
18 ms |
448 KB |
# of queries: 2680 |
6 |
Correct |
26 ms |
600 KB |
# of queries: 2727 |
7 |
Correct |
20 ms |
344 KB |
# of queries: 2736 |
8 |
Correct |
16 ms |
344 KB |
# of queries: 2590 |
9 |
Correct |
26 ms |
448 KB |
# of queries: 2710 |
10 |
Correct |
16 ms |
344 KB |
# of queries: 1572 |
11 |
Runtime error |
1 ms |
344 KB |
Execution killed with signal 13 |
12 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
17 ms |
344 KB |
# of queries: 2563 |
2 |
Correct |
21 ms |
344 KB |
# of queries: 2599 |
3 |
Correct |
28 ms |
344 KB |
# of queries: 2816 |
4 |
Correct |
24 ms |
344 KB |
# of queries: 2765 |
5 |
Correct |
18 ms |
448 KB |
# of queries: 2680 |
6 |
Correct |
26 ms |
600 KB |
# of queries: 2727 |
7 |
Correct |
20 ms |
344 KB |
# of queries: 2736 |
8 |
Correct |
16 ms |
344 KB |
# of queries: 2590 |
9 |
Correct |
26 ms |
448 KB |
# of queries: 2710 |
10 |
Correct |
16 ms |
344 KB |
# of queries: 1572 |
11 |
Runtime error |
1 ms |
344 KB |
Execution killed with signal 13 |
12 |
Halted |
0 ms |
0 KB |
- |