#include "library.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
int n;
vector<int> ans;
vector<int> rem;
vector<int> test;
void dnc(int s,int e){
if(s>=e){
ans.pb(rem[s]);
return;
}
int m=(s+e)/2;
for(int i=0;i<n;i++)test[i]=0;
for(int i=s;i<=m;i++)test[rem[i]]=1;
int cur=Query(test);
for(int i=0;i<(int)ans.size();i++)test[ans[i]]=1;
if(cur==Query(test)){ // the answer is in the first half
dnc(s,m);
}else{
dnc(m+1,e);
}
}
void Solve(int N){
n=N;
if(n==1){
vector<int> ans;
ans.pb(1);
Answer(ans);
return;
}
int endpt=0;
vector<int> m(n);
for(int i=0;i<n;i++)m[i]=1;
for(;endpt<n;endpt++){
m[endpt]=0;
if(Query(m)==1)break;
m[endpt]=1;
}
test.resize(n);
ans.pb(endpt);
for(int i=0;i<n;i++)if(i!=endpt)rem.push_back(i);
for(int i=1;i<n;i++){
dnc(0,n-i-1);
for(int j=0;j<(int)rem.size()-1;j++){
if(rem[j]>=ans[i])rem[j]=rem[j+1];
}
rem.pop_back();
}
for(int i=0;i<n;i++)ans[i]++;
Answer(ans);
}
/*
5
4
2
5
3
1
9
7
2
1
6
4
8
3
9
5
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
40 ms |
364 KB |
# of queries: 2387 |
2 |
Correct |
39 ms |
364 KB |
# of queries: 2433 |
3 |
Correct |
39 ms |
364 KB |
# of queries: 2638 |
4 |
Correct |
38 ms |
364 KB |
# of queries: 2593 |
5 |
Correct |
26 ms |
376 KB |
# of queries: 2504 |
6 |
Correct |
39 ms |
364 KB |
# of queries: 2553 |
7 |
Correct |
36 ms |
364 KB |
# of queries: 2568 |
8 |
Correct |
42 ms |
364 KB |
# of queries: 2402 |
9 |
Correct |
38 ms |
364 KB |
# of queries: 2512 |
10 |
Correct |
21 ms |
364 KB |
# of queries: 1478 |
11 |
Correct |
1 ms |
364 KB |
# of queries: 0 |
12 |
Correct |
1 ms |
364 KB |
# of queries: 1 |
13 |
Correct |
1 ms |
364 KB |
# of queries: 4 |
14 |
Correct |
1 ms |
364 KB |
# of queries: 7 |
15 |
Correct |
2 ms |
304 KB |
# of queries: 73 |
16 |
Correct |
4 ms |
364 KB |
# of queries: 187 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
40 ms |
364 KB |
# of queries: 2387 |
2 |
Correct |
39 ms |
364 KB |
# of queries: 2433 |
3 |
Correct |
39 ms |
364 KB |
# of queries: 2638 |
4 |
Correct |
38 ms |
364 KB |
# of queries: 2593 |
5 |
Correct |
26 ms |
376 KB |
# of queries: 2504 |
6 |
Correct |
39 ms |
364 KB |
# of queries: 2553 |
7 |
Correct |
36 ms |
364 KB |
# of queries: 2568 |
8 |
Correct |
42 ms |
364 KB |
# of queries: 2402 |
9 |
Correct |
38 ms |
364 KB |
# of queries: 2512 |
10 |
Correct |
21 ms |
364 KB |
# of queries: 1478 |
11 |
Correct |
1 ms |
364 KB |
# of queries: 0 |
12 |
Correct |
1 ms |
364 KB |
# of queries: 1 |
13 |
Correct |
1 ms |
364 KB |
# of queries: 4 |
14 |
Correct |
1 ms |
364 KB |
# of queries: 7 |
15 |
Correct |
2 ms |
304 KB |
# of queries: 73 |
16 |
Correct |
4 ms |
364 KB |
# of queries: 187 |
17 |
Correct |
383 ms |
392 KB |
# of queries: 18008 |
18 |
Correct |
340 ms |
364 KB |
# of queries: 17231 |
19 |
Correct |
395 ms |
392 KB |
# of queries: 17451 |
20 |
Correct |
357 ms |
392 KB |
# of queries: 16277 |
21 |
Correct |
266 ms |
512 KB |
# of queries: 15362 |
22 |
Correct |
336 ms |
392 KB |
# of queries: 17617 |
23 |
Correct |
348 ms |
512 KB |
# of queries: 17170 |
24 |
Correct |
150 ms |
364 KB |
# of queries: 7885 |
25 |
Correct |
371 ms |
364 KB |
# of queries: 17118 |
26 |
Correct |
298 ms |
364 KB |
# of queries: 15989 |
27 |
Correct |
129 ms |
384 KB |
# of queries: 7994 |
28 |
Correct |
359 ms |
492 KB |
# of queries: 17935 |
29 |
Correct |
307 ms |
492 KB |
# of queries: 17915 |
30 |
Correct |
344 ms |
492 KB |
# of queries: 17935 |