#include<bits/stdc++.h>
#include"library.h"
#ifdef EVAL
#define cout cerr
#else
#include"grader.cpp"
#endif
using namespace std;
vector<int>g[205],ans;
void dfs(int v,int p){
ans.push_back(v+1);
for(int to:g[v])if(to!=p)dfs(to,v);
}
void Solve(int n){
vector<int>m(n,0);
for(int i=0;i+1<n;i++){
for(int j=i+1;j<n;j++){
m[i]=m[j]=1;
if(Query(m)==1){
g[i].push_back(j);
g[j].push_back(i);
}
m[i]=m[j]=0;
}
}
int root;
if(n==1)root=0;
else{
int l=0,r=n-1;
while(l<r){
cout<<l<<" "<<r<<endl;
int mid=(l+r)>>1;
vector<int>tmp=m;
for(int i=l;i<=mid;i++)tmp[i]=1;
int x=Query(tmp);
for(auto &to:tmp)to^=1;
int y=Query(tmp);
if(x>=y)r=mid;
else l=mid+1;
}
root=l;
}
dfs(root,root);
Answer(ans);
}
/*
9
7 2 1 6 4 8 3 9 5
*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
246 ms |
384 KB |
# of queries: 18352 |
2 |
Correct |
282 ms |
364 KB |
# of queries: 18159 |
3 |
Correct |
318 ms |
388 KB |
# of queries: 19916 |
4 |
Correct |
312 ms |
516 KB |
# of queries: 19914 |
5 |
Correct |
322 ms |
384 KB |
# of queries: 19916 |
6 |
Correct |
355 ms |
364 KB |
# of queries: 19916 |
7 |
Correct |
348 ms |
364 KB |
# of queries: 19916 |
8 |
Correct |
317 ms |
364 KB |
# of queries: 18542 |
9 |
Correct |
337 ms |
492 KB |
# of queries: 19717 |
10 |
Correct |
131 ms |
492 KB |
# of queries: 8270 |
11 |
Correct |
1 ms |
364 KB |
# of queries: 0 |
12 |
Correct |
1 ms |
492 KB |
# of queries: 3 |
13 |
Correct |
1 ms |
364 KB |
# of queries: 7 |
14 |
Correct |
1 ms |
364 KB |
# of queries: 10 |
15 |
Correct |
2 ms |
364 KB |
# of queries: 113 |
16 |
Correct |
5 ms |
364 KB |
# of queries: 361 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
246 ms |
384 KB |
# of queries: 18352 |
2 |
Correct |
282 ms |
364 KB |
# of queries: 18159 |
3 |
Correct |
318 ms |
388 KB |
# of queries: 19916 |
4 |
Correct |
312 ms |
516 KB |
# of queries: 19914 |
5 |
Correct |
322 ms |
384 KB |
# of queries: 19916 |
6 |
Correct |
355 ms |
364 KB |
# of queries: 19916 |
7 |
Correct |
348 ms |
364 KB |
# of queries: 19916 |
8 |
Correct |
317 ms |
364 KB |
# of queries: 18542 |
9 |
Correct |
337 ms |
492 KB |
# of queries: 19717 |
10 |
Correct |
131 ms |
492 KB |
# of queries: 8270 |
11 |
Correct |
1 ms |
364 KB |
# of queries: 0 |
12 |
Correct |
1 ms |
492 KB |
# of queries: 3 |
13 |
Correct |
1 ms |
364 KB |
# of queries: 7 |
14 |
Correct |
1 ms |
364 KB |
# of queries: 10 |
15 |
Correct |
2 ms |
364 KB |
# of queries: 113 |
16 |
Correct |
5 ms |
364 KB |
# of queries: 361 |
17 |
Runtime error |
10 ms |
492 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
18 |
Halted |
0 ms |
0 KB |
- |