#include<bits/stdc++.h>
#include "library.h"
using namespace std;
void Solve(int n){
vector<int> res;
vector<int> q(n, 1);
vector<int> t(n);
iota(t.begin(), t.end(), 1);
for(int i = 1; i <= n; i ++){
q[i - 1] = 0;
if(Query(q) == 1){
res.push_back(i);
t.erase(t.begin() + i - 1);
q[i - 1] = 1;
break;
}
q[i - 1] = 1;
}
q = vector<int>(n, 0);
while((int)res.size() < n){
int l = 0, r = (int)t.size() - 1;
while(l < r){
int m = (l + r) / 2;
for(int i = l; i <= m; i ++) q[t[i] - 1] = 1;
int res1 = Query(q);
q[res.back() - 1] = 1;
int res2 = Query(q);
q[res.back() - 1] = 0;
for(int i = l; i <= m; i ++) q[t[i] - 1] = 0;
if(res1 == res2) r = m;
else l = m + 1;
}
res.push_back(t[l]);
t.erase(t.begin() + l);
}
Answer(res);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
23 ms |
380 KB |
# of queries: 2387 |
2 |
Correct |
33 ms |
256 KB |
# of queries: 2433 |
3 |
Correct |
39 ms |
256 KB |
# of queries: 2638 |
4 |
Correct |
36 ms |
256 KB |
# of queries: 2593 |
5 |
Correct |
23 ms |
408 KB |
# of queries: 2504 |
6 |
Correct |
26 ms |
372 KB |
# of queries: 2553 |
7 |
Correct |
38 ms |
256 KB |
# of queries: 2568 |
8 |
Correct |
36 ms |
256 KB |
# of queries: 2402 |
9 |
Correct |
34 ms |
256 KB |
# of queries: 2512 |
10 |
Correct |
20 ms |
256 KB |
# of queries: 1478 |
11 |
Incorrect |
0 ms |
256 KB |
Wrong Answer [2] |
12 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
23 ms |
380 KB |
# of queries: 2387 |
2 |
Correct |
33 ms |
256 KB |
# of queries: 2433 |
3 |
Correct |
39 ms |
256 KB |
# of queries: 2638 |
4 |
Correct |
36 ms |
256 KB |
# of queries: 2593 |
5 |
Correct |
23 ms |
408 KB |
# of queries: 2504 |
6 |
Correct |
26 ms |
372 KB |
# of queries: 2553 |
7 |
Correct |
38 ms |
256 KB |
# of queries: 2568 |
8 |
Correct |
36 ms |
256 KB |
# of queries: 2402 |
9 |
Correct |
34 ms |
256 KB |
# of queries: 2512 |
10 |
Correct |
20 ms |
256 KB |
# of queries: 1478 |
11 |
Incorrect |
0 ms |
256 KB |
Wrong Answer [2] |
12 |
Halted |
0 ms |
0 KB |
- |