#include<bits/stdc++.h>
#include "library.h"
using namespace std;
int C = 0;
void F(){
++C;
assert(C <= 20000);
}
void Solve(int N){
vector<int> ans , e(N) , tx(N);
for(int i = 0;i < N;i ++){
tx[i] = e[i] = 1;
}
int L = -1;
for(int i = 0;i < N;i ++){
tx[i] = 0;
F();
if(Query(tx) == 1){
L = i;
break;
}
tx[i] = 1;
}
if(L == -1){
exit(0);
}
e[L] = 0;
ans.push_back(L);
for(int r = 1;r < N;r ++){
int pos = 0;
for(int bit = 9;bit >= 0;bit --){
int _pos = pos + (1 << bit);
if(_pos < N - r){
vector<int> u(N);
for(int i = 0;i < N;i ++){
if(_pos > 0 && e[i]){
--_pos;
u[i] = 1;
}
}
F();
int bef = Query(u);
u[ans.back()] = 1;
F();
int now = Query(u);
if(bef != now){
pos += (1 << bit);
}
}
}
++pos;
for(int i = 0;i < N;i ++){
if(e[i]){
--pos;
}
if(pos == 0){
pos = i;
break;
}
}
ans.push_back(pos);
e[pos] = 0;
}
for(int i = 0;i < N;i ++){
++ans[i];
}
Answer(ans);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
16 ms |
344 KB |
# of queries: 2477 |
2 |
Correct |
21 ms |
344 KB |
# of queries: 2471 |
3 |
Correct |
24 ms |
344 KB |
# of queries: 2736 |
4 |
Correct |
25 ms |
340 KB |
# of queries: 2669 |
5 |
Correct |
27 ms |
344 KB |
# of queries: 2572 |
6 |
Correct |
24 ms |
344 KB |
# of queries: 2639 |
7 |
Correct |
24 ms |
344 KB |
# of queries: 2670 |
8 |
Correct |
26 ms |
344 KB |
# of queries: 2504 |
9 |
Correct |
20 ms |
344 KB |
# of queries: 2626 |
10 |
Correct |
10 ms |
344 KB |
# of queries: 1540 |
11 |
Incorrect |
0 ms |
344 KB |
Wrong Answer [2] |
12 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
16 ms |
344 KB |
# of queries: 2477 |
2 |
Correct |
21 ms |
344 KB |
# of queries: 2471 |
3 |
Correct |
24 ms |
344 KB |
# of queries: 2736 |
4 |
Correct |
25 ms |
340 KB |
# of queries: 2669 |
5 |
Correct |
27 ms |
344 KB |
# of queries: 2572 |
6 |
Correct |
24 ms |
344 KB |
# of queries: 2639 |
7 |
Correct |
24 ms |
344 KB |
# of queries: 2670 |
8 |
Correct |
26 ms |
344 KB |
# of queries: 2504 |
9 |
Correct |
20 ms |
344 KB |
# of queries: 2626 |
10 |
Correct |
10 ms |
344 KB |
# of queries: 1540 |
11 |
Incorrect |
0 ms |
344 KB |
Wrong Answer [2] |
12 |
Halted |
0 ms |
0 KB |
- |