#include <cstdio>
#include <vector>
#include "library.h"
#include<bits/stdc++.h>
using namespace std;
int adj[10005][2],st=1;
void Solve(int n){
vector<int> M(n), K, K2;
for(int i=1;i<=n;i++){
int be = 1, ed = n, mid, mi = 1e9;
while(be <= ed){
mid = (be+ed)/2;
// printf(">> %d %d\n",i,mid);
K = M;
for(int j=1;j<=mid;j++) K[j-1] = 1;
K2 = K;
K[i-1] = 1, K2[i-1] = 0;
int A;
if(K2 == M) A = 0;
else A = Query(K2);
if(Query(K) <= A){
ed = mid - 1;
mi = min(mi,mid);
}
else be = mid + 1;
}
adj[i][0] = mi;
be = mi+1, ed = n, mid;
int mm = mi + 1;
mi = 1e9;
while(be <= ed){
mid = (be+ed)/2;
K = M;
for(int j=mm;j<=mid;j++) K[j-1] = 1;
K2 = K;
K[i-1] = 1, K2[i-1] = 0;
int A;
if(K2 == M) A = 0;
else A = Query(K2);
if(Query(K) <= A){
ed = mid - 1;
mi = min(mi,mid);
}
else be = mid + 1;
}
if(mi == 1e9){
adj[i][1] = -1;
st = i;
}
else adj[i][1] = mi;
}
vector<int> res;
int pos = st, pre = -1;
while(pos != -1){
res.push_back(pos);
int kk = pos;
if(adj[pos][0] != pre) pos = adj[pos][0];
else pos = adj[pos][1];
pre = kk;
}
Answer(res);
}
Compilation message
library.cpp: In function 'void Solve(int)':
library.cpp:32:25: warning: right operand of comma operator has no effect [-Wunused-value]
32 | be = mi+1, ed = n, mid;
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
81 ms |
208 KB |
# of queries: 5580 |
2 |
Correct |
74 ms |
208 KB |
# of queries: 5582 |
3 |
Correct |
75 ms |
208 KB |
# of queries: 5864 |
4 |
Correct |
82 ms |
208 KB |
# of queries: 5904 |
5 |
Correct |
77 ms |
208 KB |
# of queries: 5890 |
6 |
Correct |
84 ms |
208 KB |
# of queries: 5894 |
7 |
Correct |
84 ms |
208 KB |
# of queries: 5886 |
8 |
Correct |
75 ms |
208 KB |
# of queries: 5630 |
9 |
Correct |
79 ms |
208 KB |
# of queries: 5862 |
10 |
Correct |
43 ms |
208 KB |
# of queries: 3446 |
11 |
Runtime error |
1 ms |
336 KB |
Execution killed with signal 11 |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
81 ms |
208 KB |
# of queries: 5580 |
2 |
Correct |
74 ms |
208 KB |
# of queries: 5582 |
3 |
Correct |
75 ms |
208 KB |
# of queries: 5864 |
4 |
Correct |
82 ms |
208 KB |
# of queries: 5904 |
5 |
Correct |
77 ms |
208 KB |
# of queries: 5890 |
6 |
Correct |
84 ms |
208 KB |
# of queries: 5894 |
7 |
Correct |
84 ms |
208 KB |
# of queries: 5886 |
8 |
Correct |
75 ms |
208 KB |
# of queries: 5630 |
9 |
Correct |
79 ms |
208 KB |
# of queries: 5862 |
10 |
Correct |
43 ms |
208 KB |
# of queries: 3446 |
11 |
Runtime error |
1 ms |
336 KB |
Execution killed with signal 11 |
12 |
Halted |
0 ms |
0 KB |
- |