#include "library.h"
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e3 + 5;
int n;
vector<int> way[maxn];
vector<int> ans;
int ask(int l, int r, int x) {
vector<int> vec;
for(int i=1;i<=n;i++) {
if(i==x || (l<=i && i<=r)) vec.push_back(1);
else vec.push_back(0);
}
return Query(vec);
}
void addedge(int x, int l, int r) {
if(l>r) return ;
// printf("ask [%d, %d] : %d = %d original = %d\n",l,r,x,ask(l,r,x),ask(l,r,0));
if(ask(l,r,x)>ask(l,r,0)) return ;
if(l==r) {
// printf("%d <-> %d\n",l,x);
way[x].push_back(l);
way[l].push_back(x);
return ;
}
int mid = (l+r)/2;
addedge(x,l,mid); addedge(x,mid+1,r);
}
void dfs(int u, int last) {
// printf("dfs %d\n",u,last);
ans.push_back(u);
for(auto v : way[u]) {
if(v==last) continue;
dfs(v, u);
}
}
void Solve(int N) {
if(N==1) {
Answer({1});
return ;
}
n = N;
ans.clear();
for(int x=1;x<=n;x++) addedge(x,1,x-1);
for(int x=1;x<=n;x++) {
if(way[x].size()==1) {
dfs(x, 0);
Answer(ans);
return ;
}
}
for(int i=1;i<=n;i++) way[i].clear();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
99 ms |
328 KB |
Output is correct |
2 |
Correct |
82 ms |
440 KB |
Output is correct |
3 |
Correct |
83 ms |
516 KB |
Output is correct |
4 |
Correct |
87 ms |
516 KB |
Output is correct |
5 |
Correct |
80 ms |
516 KB |
Output is correct |
6 |
Correct |
94 ms |
616 KB |
Output is correct |
7 |
Correct |
104 ms |
620 KB |
Output is correct |
8 |
Correct |
74 ms |
648 KB |
Output is correct |
9 |
Correct |
86 ms |
648 KB |
Output is correct |
10 |
Correct |
46 ms |
648 KB |
Output is correct |
11 |
Correct |
2 ms |
648 KB |
Output is correct |
12 |
Correct |
2 ms |
648 KB |
Output is correct |
13 |
Correct |
2 ms |
648 KB |
Output is correct |
14 |
Correct |
2 ms |
648 KB |
Output is correct |
15 |
Correct |
5 ms |
648 KB |
Output is correct |
16 |
Correct |
8 ms |
648 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
99 ms |
328 KB |
Output is correct |
2 |
Correct |
82 ms |
440 KB |
Output is correct |
3 |
Correct |
83 ms |
516 KB |
Output is correct |
4 |
Correct |
87 ms |
516 KB |
Output is correct |
5 |
Correct |
80 ms |
516 KB |
Output is correct |
6 |
Correct |
94 ms |
616 KB |
Output is correct |
7 |
Correct |
104 ms |
620 KB |
Output is correct |
8 |
Correct |
74 ms |
648 KB |
Output is correct |
9 |
Correct |
86 ms |
648 KB |
Output is correct |
10 |
Correct |
46 ms |
648 KB |
Output is correct |
11 |
Correct |
2 ms |
648 KB |
Output is correct |
12 |
Correct |
2 ms |
648 KB |
Output is correct |
13 |
Correct |
2 ms |
648 KB |
Output is correct |
14 |
Correct |
2 ms |
648 KB |
Output is correct |
15 |
Correct |
5 ms |
648 KB |
Output is correct |
16 |
Correct |
8 ms |
648 KB |
Output is correct |
17 |
Execution timed out |
2005 ms |
984 KB |
Time limit exceeded |
18 |
Halted |
0 ms |
0 KB |
- |