#include<bits/stdc++.h>
#include "library.h"
using namespace std;
void Solve(int n)
{
vector<int> res(n);
vector<int> ask(n , 1);
int pre = 0;
vector<int> p(n);
for(int i = 0 ; i < n ; ++i)p[i] = i;
auto del = [&](int x){
p.erase(find(p.begin(),p.end(),x));
};
for(int i = 0 ; i < n ; ++i){
ask[i] = 0;
if(Query(ask) == 1){
pre = i;
break;
}
ask[i] = 1;
}
del(pre);res[0] = pre;
if(n == 1){
Answer(res);
return;
}
for(int i = 1 ; i < n ; ++i){
int l = 0 , h = (int)p.size() - 1;
while(l <= h){
for(int j = 0 ; j < n ; ++j)ask[j] = 0;
int mid = l + h >> 1;
for(int j = 0 ; j <= mid ; ++j)ask[p[j]] = 1;
int last = Query(ask);
ask[pre] = 1;
if(last == Query(ask))h = mid - 1;
else l = mid + 1;
}
pre = p[l];
del(pre);
res[i] = pre;
}
for(int i = 0 ; i < n ; ++i)res[i]++;
Answer(res);
}
Compilation message
library.cpp: In function 'void Solve(int)':
library.cpp:32:25: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
int mid = l + h >> 1;
~~^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
51 ms |
248 KB |
# of queries: 2401 |
2 |
Correct |
42 ms |
248 KB |
# of queries: 2437 |
3 |
Correct |
51 ms |
376 KB |
# of queries: 2658 |
4 |
Correct |
42 ms |
376 KB |
# of queries: 2597 |
5 |
Correct |
49 ms |
376 KB |
# of queries: 2526 |
6 |
Correct |
45 ms |
376 KB |
# of queries: 2565 |
7 |
Correct |
42 ms |
248 KB |
# of queries: 2556 |
8 |
Correct |
47 ms |
376 KB |
# of queries: 2424 |
9 |
Correct |
41 ms |
376 KB |
# of queries: 2550 |
10 |
Correct |
33 ms |
376 KB |
# of queries: 1488 |
11 |
Incorrect |
2 ms |
248 KB |
Wrong Answer [2] |
12 |
Correct |
2 ms |
248 KB |
# of queries: 3 |
13 |
Correct |
2 ms |
248 KB |
# of queries: 6 |
14 |
Correct |
3 ms |
376 KB |
# of queries: 9 |
15 |
Correct |
3 ms |
376 KB |
# of queries: 79 |
16 |
Correct |
7 ms |
376 KB |
# of queries: 195 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
51 ms |
248 KB |
# of queries: 2401 |
2 |
Correct |
42 ms |
248 KB |
# of queries: 2437 |
3 |
Correct |
51 ms |
376 KB |
# of queries: 2658 |
4 |
Correct |
42 ms |
376 KB |
# of queries: 2597 |
5 |
Correct |
49 ms |
376 KB |
# of queries: 2526 |
6 |
Correct |
45 ms |
376 KB |
# of queries: 2565 |
7 |
Correct |
42 ms |
248 KB |
# of queries: 2556 |
8 |
Correct |
47 ms |
376 KB |
# of queries: 2424 |
9 |
Correct |
41 ms |
376 KB |
# of queries: 2550 |
10 |
Correct |
33 ms |
376 KB |
# of queries: 1488 |
11 |
Incorrect |
2 ms |
248 KB |
Wrong Answer [2] |
12 |
Correct |
2 ms |
248 KB |
# of queries: 3 |
13 |
Correct |
2 ms |
248 KB |
# of queries: 6 |
14 |
Correct |
3 ms |
376 KB |
# of queries: 9 |
15 |
Correct |
3 ms |
376 KB |
# of queries: 79 |
16 |
Correct |
7 ms |
376 KB |
# of queries: 195 |
17 |
Correct |
499 ms |
248 KB |
# of queries: 18030 |
18 |
Correct |
488 ms |
376 KB |
# of queries: 17279 |
19 |
Correct |
524 ms |
376 KB |
# of queries: 17479 |
20 |
Correct |
456 ms |
248 KB |
# of queries: 16301 |
21 |
Correct |
456 ms |
248 KB |
# of queries: 15352 |
22 |
Correct |
501 ms |
376 KB |
# of queries: 17663 |
23 |
Correct |
507 ms |
376 KB |
# of queries: 17250 |
24 |
Correct |
186 ms |
296 KB |
# of queries: 7917 |
25 |
Correct |
501 ms |
248 KB |
# of queries: 17158 |
26 |
Correct |
465 ms |
248 KB |
# of queries: 16003 |
27 |
Correct |
132 ms |
248 KB |
# of queries: 8046 |
28 |
Correct |
456 ms |
248 KB |
# of queries: 15975 |
29 |
Correct |
476 ms |
296 KB |
# of queries: 15957 |
30 |
Correct |
457 ms |
248 KB |
# of queries: 15975 |