#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++){
vector<int> ask(n, 0);
ask[i] = 1;
for(int j=i+1;j<n;j++){
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 |
208 ms |
620 KB |
# of queries: 18336 |
2 |
Correct |
184 ms |
364 KB |
# of queries: 18145 |
3 |
Correct |
255 ms |
508 KB |
# of queries: 19900 |
4 |
Correct |
225 ms |
364 KB |
# of queries: 19900 |
5 |
Correct |
283 ms |
492 KB |
# of queries: 19900 |
6 |
Correct |
239 ms |
364 KB |
# of queries: 19900 |
7 |
Correct |
342 ms |
364 KB |
# of queries: 19900 |
8 |
Correct |
321 ms |
364 KB |
# of queries: 18528 |
9 |
Correct |
335 ms |
364 KB |
# of queries: 19701 |
10 |
Correct |
100 ms |
364 KB |
# of queries: 8256 |
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: 3 |
14 |
Correct |
1 ms |
364 KB |
# of queries: 6 |
15 |
Correct |
2 ms |
364 KB |
# of queries: 105 |
16 |
Correct |
6 ms |
364 KB |
# of queries: 351 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
208 ms |
620 KB |
# of queries: 18336 |
2 |
Correct |
184 ms |
364 KB |
# of queries: 18145 |
3 |
Correct |
255 ms |
508 KB |
# of queries: 19900 |
4 |
Correct |
225 ms |
364 KB |
# of queries: 19900 |
5 |
Correct |
283 ms |
492 KB |
# of queries: 19900 |
6 |
Correct |
239 ms |
364 KB |
# of queries: 19900 |
7 |
Correct |
342 ms |
364 KB |
# of queries: 19900 |
8 |
Correct |
321 ms |
364 KB |
# of queries: 18528 |
9 |
Correct |
335 ms |
364 KB |
# of queries: 19701 |
10 |
Correct |
100 ms |
364 KB |
# of queries: 8256 |
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: 3 |
14 |
Correct |
1 ms |
364 KB |
# of queries: 6 |
15 |
Correct |
2 ms |
364 KB |
# of queries: 105 |
16 |
Correct |
6 ms |
364 KB |
# of queries: 351 |
17 |
Runtime error |
372 ms |
364 KB |
Execution killed with signal 13 (could be triggered by violating memory limits) |
18 |
Halted |
0 ms |
0 KB |
- |