#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-1){
for(int i=1;i<=n;i++){
if(vis[i] == 0){
res.push_back(i);
break;
}
}
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;
int cnt = 0;
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:49:8: warning: unused variable 'cnt' [-Wunused-variable]
49 | int cnt = 0;
| ^~~
library.cpp:47:13: warning: 'be' may be used uninitialized in this function [-Wmaybe-uninitialized]
47 | mid = (be+ed)/2;
| ~~~^~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
27 ms |
208 KB |
# of queries: 2919 |
2 |
Correct |
46 ms |
304 KB |
# of queries: 2947 |
3 |
Correct |
47 ms |
208 KB |
# of queries: 3196 |
4 |
Correct |
48 ms |
208 KB |
# of queries: 3133 |
5 |
Correct |
44 ms |
208 KB |
# of queries: 3042 |
6 |
Correct |
37 ms |
208 KB |
# of queries: 3079 |
7 |
Correct |
45 ms |
208 KB |
# of queries: 3108 |
8 |
Correct |
42 ms |
308 KB |
# of queries: 2944 |
9 |
Correct |
41 ms |
208 KB |
# of queries: 3086 |
10 |
Correct |
18 ms |
208 KB |
# of queries: 1802 |
11 |
Correct |
0 ms |
208 KB |
# of queries: 0 |
12 |
Correct |
1 ms |
208 KB |
# of queries: 1 |
13 |
Correct |
0 ms |
208 KB |
# of queries: 6 |
14 |
Correct |
1 ms |
208 KB |
# of queries: 9 |
15 |
Correct |
2 ms |
208 KB |
# of queries: 99 |
16 |
Correct |
3 ms |
208 KB |
# of queries: 241 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
27 ms |
208 KB |
# of queries: 2919 |
2 |
Correct |
46 ms |
304 KB |
# of queries: 2947 |
3 |
Correct |
47 ms |
208 KB |
# of queries: 3196 |
4 |
Correct |
48 ms |
208 KB |
# of queries: 3133 |
5 |
Correct |
44 ms |
208 KB |
# of queries: 3042 |
6 |
Correct |
37 ms |
208 KB |
# of queries: 3079 |
7 |
Correct |
45 ms |
208 KB |
# of queries: 3108 |
8 |
Correct |
42 ms |
308 KB |
# of queries: 2944 |
9 |
Correct |
41 ms |
208 KB |
# of queries: 3086 |
10 |
Correct |
18 ms |
208 KB |
# of queries: 1802 |
11 |
Correct |
0 ms |
208 KB |
# of queries: 0 |
12 |
Correct |
1 ms |
208 KB |
# of queries: 1 |
13 |
Correct |
0 ms |
208 KB |
# of queries: 6 |
14 |
Correct |
1 ms |
208 KB |
# of queries: 9 |
15 |
Correct |
2 ms |
208 KB |
# of queries: 99 |
16 |
Correct |
3 ms |
208 KB |
# of queries: 241 |
17 |
Runtime error |
419 ms |
308 KB |
Execution killed with signal 13 |
18 |
Halted |
0 ms |
0 KB |
- |