#include <cstdio>
#include <vector>
#include "library.h"
//#include "grader.cpp"
#include "bits/stdc++.h"
using namespace std;
void Solve(int n)
{
if(n==1){
vector<int>ans;
ans={1};
Answer (ans);
return;
}
vector<int>q(n,1);int st=0;
for(int i=0;i<n;i++){
q[i]=0;
int x=Query(q);
q[i]=1;
if(x==1){
st=i;}
}
vector<int>ans;
ans.push_back(st);
vector<int>comp;
for(int i=0;i<n;i++){
if(i!=st){
comp.push_back(i);
}
}
while(comp.size()){
int s=0; int en=comp.size()-1;
while(s<=en){
int mid=(s+en)/2;
vector<int>Q(n,0);
for(int j=0;j<=mid;j++){
Q[comp[j]]=1;
}
int x=Query(Q);
Q[ans.back()]=1;
int y=Query(Q);
if(y==x){
en=mid-1;
}else{
s=mid+1;
}
}
ans.push_back(comp[s]);
swap(comp[s], comp.back());
comp.pop_back();
}
for(auto &it:ans){it++;
}
Answer(ans);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
36 ms |
208 KB |
# of queries: 2582 |
2 |
Correct |
35 ms |
300 KB |
# of queries: 2565 |
3 |
Correct |
39 ms |
208 KB |
# of queries: 2720 |
4 |
Correct |
48 ms |
208 KB |
# of queries: 2714 |
5 |
Correct |
37 ms |
208 KB |
# of queries: 2716 |
6 |
Correct |
36 ms |
208 KB |
# of queries: 2710 |
7 |
Correct |
37 ms |
208 KB |
# of queries: 2718 |
8 |
Correct |
38 ms |
208 KB |
# of queries: 2607 |
9 |
Correct |
36 ms |
300 KB |
# of queries: 2691 |
10 |
Correct |
15 ms |
208 KB |
# of queries: 1573 |
11 |
Correct |
0 ms |
208 KB |
# of queries: 0 |
12 |
Correct |
0 ms |
208 KB |
# of queries: 4 |
13 |
Correct |
0 ms |
208 KB |
# of queries: 7 |
14 |
Correct |
1 ms |
208 KB |
# of queries: 14 |
15 |
Correct |
1 ms |
208 KB |
# of queries: 91 |
16 |
Correct |
3 ms |
208 KB |
# of queries: 211 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
36 ms |
208 KB |
# of queries: 2582 |
2 |
Correct |
35 ms |
300 KB |
# of queries: 2565 |
3 |
Correct |
39 ms |
208 KB |
# of queries: 2720 |
4 |
Correct |
48 ms |
208 KB |
# of queries: 2714 |
5 |
Correct |
37 ms |
208 KB |
# of queries: 2716 |
6 |
Correct |
36 ms |
208 KB |
# of queries: 2710 |
7 |
Correct |
37 ms |
208 KB |
# of queries: 2718 |
8 |
Correct |
38 ms |
208 KB |
# of queries: 2607 |
9 |
Correct |
36 ms |
300 KB |
# of queries: 2691 |
10 |
Correct |
15 ms |
208 KB |
# of queries: 1573 |
11 |
Correct |
0 ms |
208 KB |
# of queries: 0 |
12 |
Correct |
0 ms |
208 KB |
# of queries: 4 |
13 |
Correct |
0 ms |
208 KB |
# of queries: 7 |
14 |
Correct |
1 ms |
208 KB |
# of queries: 14 |
15 |
Correct |
1 ms |
208 KB |
# of queries: 91 |
16 |
Correct |
3 ms |
208 KB |
# of queries: 211 |
17 |
Correct |
403 ms |
328 KB |
# of queries: 18210 |
18 |
Correct |
400 ms |
328 KB |
# of queries: 17935 |
19 |
Correct |
377 ms |
292 KB |
# of queries: 18218 |
20 |
Correct |
373 ms |
340 KB |
# of queries: 16922 |
21 |
Correct |
268 ms |
328 KB |
# of queries: 15961 |
22 |
Correct |
380 ms |
296 KB |
# of queries: 18208 |
23 |
Correct |
431 ms |
284 KB |
# of queries: 18195 |
24 |
Correct |
142 ms |
300 KB |
# of queries: 8315 |
25 |
Correct |
393 ms |
412 KB |
# of queries: 17711 |
26 |
Correct |
298 ms |
292 KB |
# of queries: 16581 |
27 |
Correct |
139 ms |
336 KB |
# of queries: 8297 |
28 |
Correct |
475 ms |
296 KB |
# of queries: 18954 |
29 |
Correct |
472 ms |
300 KB |
# of queries: 18933 |
30 |
Correct |
447 ms |
300 KB |
# of queries: 18954 |