#include <cstdio>
#include <vector>
#include "library.h"
#include<bits/stdc++.h>
using namespace std;
int adj[1005][2],st=0,vis[1005];
void Solve(int n){
vector<int> res;
if(n == 1){
res.push_back(1);
Answer(res);
return;
}
vector<int> M(n), K, K2;
K = M;
for(int i=1;i<=n;i++) K[i-1] = 1;
for(int i=1;i<=n;i++){
K[i-1] = 0;
if(Query(K) == 1){
st = i;
break;
}
K[i-1] = 1;
}
int pos = st,pre = -1;
for(int i=1;i<=n;i++){
res.push_back(pos);
vis[pos] = 1;
if(i == n) break;
int be,ed = n, mid, mi = 1e9, keep = pos;
for(int i=1;i<=n;i++)
if(vis[i] == 0){
be = i;
break;
}
while(be <= ed){
mid = (be+ed)/2;
K = M;
for(int j=1;j<=mid;j++) if(j != pre) K[j-1] = 1;
K2 = K;
K[pos-1] = 1, K2[pos-1] = 0;
int A,B;
if(K2 == M) A = 0, B = 1;
else A = Query(K2), B = Query(K);
if(B <= A){
ed = mid - 1;
mi = min(mi,mid);
}
else be = mid + 1;
}
pos = mi;
pre = keep;
}
Answer(res);
}
Compilation message
library.cpp: In function 'void Solve(int)':
library.cpp:39:13: warning: 'be' may be used uninitialized in this function [-Wmaybe-uninitialized]
39 | mid = (be+ed)/2;
| ~~~^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
30 ms |
228 KB |
# of queries: 2931 |
2 |
Correct |
43 ms |
208 KB |
# of queries: 2957 |
3 |
Correct |
47 ms |
304 KB |
# of queries: 3204 |
4 |
Correct |
42 ms |
208 KB |
# of queries: 3145 |
5 |
Correct |
30 ms |
308 KB |
# of queries: 3050 |
6 |
Correct |
47 ms |
208 KB |
# of queries: 3091 |
7 |
Correct |
42 ms |
208 KB |
# of queries: 3116 |
8 |
Correct |
40 ms |
208 KB |
# of queries: 2958 |
9 |
Correct |
30 ms |
208 KB |
# of queries: 3096 |
10 |
Correct |
25 ms |
208 KB |
# of queries: 1812 |
11 |
Correct |
0 ms |
208 KB |
# of queries: 0 |
12 |
Correct |
1 ms |
208 KB |
# of queries: 3 |
13 |
Correct |
1 ms |
356 KB |
# of queries: 8 |
14 |
Correct |
0 ms |
208 KB |
# of queries: 11 |
15 |
Correct |
2 ms |
208 KB |
# of queries: 105 |
16 |
Correct |
4 ms |
208 KB |
# of queries: 245 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
30 ms |
228 KB |
# of queries: 2931 |
2 |
Correct |
43 ms |
208 KB |
# of queries: 2957 |
3 |
Correct |
47 ms |
304 KB |
# of queries: 3204 |
4 |
Correct |
42 ms |
208 KB |
# of queries: 3145 |
5 |
Correct |
30 ms |
308 KB |
# of queries: 3050 |
6 |
Correct |
47 ms |
208 KB |
# of queries: 3091 |
7 |
Correct |
42 ms |
208 KB |
# of queries: 3116 |
8 |
Correct |
40 ms |
208 KB |
# of queries: 2958 |
9 |
Correct |
30 ms |
208 KB |
# of queries: 3096 |
10 |
Correct |
25 ms |
208 KB |
# of queries: 1812 |
11 |
Correct |
0 ms |
208 KB |
# of queries: 0 |
12 |
Correct |
1 ms |
208 KB |
# of queries: 3 |
13 |
Correct |
1 ms |
356 KB |
# of queries: 8 |
14 |
Correct |
0 ms |
208 KB |
# of queries: 11 |
15 |
Correct |
2 ms |
208 KB |
# of queries: 105 |
16 |
Correct |
4 ms |
208 KB |
# of queries: 245 |
17 |
Runtime error |
451 ms |
308 KB |
Execution killed with signal 13 |
18 |
Halted |
0 ms |
0 KB |
- |