#include <bits/stdc++.h>
#include "library.h"
//~ #include "grader.cpp"
using namespace std;
void Solve(int n){
if(n == 1){
vector<int> ans = {1};
Answer(ans);
return;
}
vector<vector<int>> v(n);
for(int i=0;i<n;i++){
if(v[i].size() == 2)continue;
vector<int> ask(n, 0);
ask[i] = 1;
for(int j=i+1;j<n;j++){
if(v[j].size() == 2)continue;
ask[j] = 1;
if(Query(ask) == 1)v[i].push_back(j), v[j].push_back(i);
ask[j] = 0;
}
}
//~ for(int i=0;i<n;i++){for(auto x : v[i])cout << x << ' ';cout << '\n';}
vector<bool> used(n);
vector<int> ans;
int u=-1;
for(int i=0;i<n;i++){
if(v[i].size() == 1){
u = i;break;
}
}
assert(u != -1);
while(true){
bool ch = false;
used[u] = true;
ans.push_back(u+1);
for(auto to : v[u]){
if(!used[to]){
ch=true;
u=to;
}
}if(!ch)break;
}
Answer(ans);
return;
}
/*
5
4 2 5 3 1
*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
199 ms |
364 KB |
# of queries: 12639 |
2 |
Correct |
203 ms |
492 KB |
# of queries: 13346 |
3 |
Correct |
205 ms |
364 KB |
# of queries: 14103 |
4 |
Correct |
212 ms |
384 KB |
# of queries: 14987 |
5 |
Correct |
175 ms |
380 KB |
# of queries: 14879 |
6 |
Correct |
175 ms |
492 KB |
# of queries: 14661 |
7 |
Correct |
199 ms |
364 KB |
# of queries: 14811 |
8 |
Correct |
176 ms |
364 KB |
# of queries: 14128 |
9 |
Correct |
182 ms |
492 KB |
# of queries: 14232 |
10 |
Correct |
80 ms |
364 KB |
# of queries: 5988 |
11 |
Correct |
0 ms |
364 KB |
# of queries: 0 |
12 |
Correct |
0 ms |
364 KB |
# of queries: 1 |
13 |
Correct |
1 ms |
364 KB |
# of queries: 3 |
14 |
Correct |
1 ms |
364 KB |
# of queries: 5 |
15 |
Correct |
1 ms |
364 KB |
# of queries: 79 |
16 |
Correct |
4 ms |
364 KB |
# of queries: 275 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
199 ms |
364 KB |
# of queries: 12639 |
2 |
Correct |
203 ms |
492 KB |
# of queries: 13346 |
3 |
Correct |
205 ms |
364 KB |
# of queries: 14103 |
4 |
Correct |
212 ms |
384 KB |
# of queries: 14987 |
5 |
Correct |
175 ms |
380 KB |
# of queries: 14879 |
6 |
Correct |
175 ms |
492 KB |
# of queries: 14661 |
7 |
Correct |
199 ms |
364 KB |
# of queries: 14811 |
8 |
Correct |
176 ms |
364 KB |
# of queries: 14128 |
9 |
Correct |
182 ms |
492 KB |
# of queries: 14232 |
10 |
Correct |
80 ms |
364 KB |
# of queries: 5988 |
11 |
Correct |
0 ms |
364 KB |
# of queries: 0 |
12 |
Correct |
0 ms |
364 KB |
# of queries: 1 |
13 |
Correct |
1 ms |
364 KB |
# of queries: 3 |
14 |
Correct |
1 ms |
364 KB |
# of queries: 5 |
15 |
Correct |
1 ms |
364 KB |
# of queries: 79 |
16 |
Correct |
4 ms |
364 KB |
# of queries: 275 |
17 |
Runtime error |
325 ms |
364 KB |
Execution killed with signal 13 (could be triggered by violating memory limits) |
18 |
Halted |
0 ms |
0 KB |
- |