#include "library.h"
#include<bits/stdc++.h>
using namespace std;
int ask(vector < int > &V){
return Query(V);
}
int n;
int Find(int n){
if(n == 1){
return 0;
}
vector < int > a(n);
for(int i = 0; i < n; i++){
a[i] = 1;
}
for(int i = 0; i < n; i++){
a[i] = 0;
if(ask(a) == 1){
return i;
}
a[i] = 1;
}
return 0;
}
vector < int > a, b;
vector < bool > used;
int Find_next(int l, int r, vector < int > &vec){
if(l == r){
return vec[l];
}
int mid = (r + l) >> 1;
for(int i = l; i <= mid; i++){
a[vec[i]] = b[vec[i]] = true;
}
int x = ask(a), y = ask(b);
for(int i = l; i <= mid; i++){
a[vec[i]] = b[vec[i]] = false;
}
if(x == y){
return Find_next(l, mid, vec);
}
else{
return Find_next(mid + 1, r, vec);
}
}
void Solve(int N){
n = N;
a.resize(n, 0);
b.resize(n, 0);
used.resize(n, false);
vector < int > ans(n);
int pos = Find(n);
a[pos] = 1;
ans[0] = pos + 1;
used[pos] = true;
for(int i = 1; i < n; i++){
vector < int > vec;
for(int j = 0; j < n; j++){
if(!used[j]){
vec.push_back(j);
}
}
int nxt = Find_next(0, (int)vec.size() - 1, vec);
ans[i] = nxt + 1;
used[nxt] = true;
a[nxt] = 1;
}
Answer(ans);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
33 ms |
248 KB |
# of queries: 2387 |
2 |
Correct |
35 ms |
376 KB |
# of queries: 2433 |
3 |
Correct |
34 ms |
376 KB |
# of queries: 2638 |
4 |
Correct |
35 ms |
248 KB |
# of queries: 2593 |
5 |
Correct |
28 ms |
376 KB |
# of queries: 2504 |
6 |
Correct |
37 ms |
248 KB |
# of queries: 2553 |
7 |
Correct |
42 ms |
292 KB |
# of queries: 2568 |
8 |
Correct |
40 ms |
376 KB |
# of queries: 2402 |
9 |
Correct |
37 ms |
248 KB |
# of queries: 2512 |
10 |
Correct |
20 ms |
376 KB |
# of queries: 1478 |
11 |
Correct |
2 ms |
248 KB |
# of queries: 0 |
12 |
Correct |
2 ms |
248 KB |
# of queries: 1 |
13 |
Correct |
2 ms |
248 KB |
# of queries: 4 |
14 |
Correct |
2 ms |
376 KB |
# of queries: 7 |
15 |
Correct |
2 ms |
248 KB |
# of queries: 73 |
16 |
Correct |
4 ms |
248 KB |
# of queries: 187 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
33 ms |
248 KB |
# of queries: 2387 |
2 |
Correct |
35 ms |
376 KB |
# of queries: 2433 |
3 |
Correct |
34 ms |
376 KB |
# of queries: 2638 |
4 |
Correct |
35 ms |
248 KB |
# of queries: 2593 |
5 |
Correct |
28 ms |
376 KB |
# of queries: 2504 |
6 |
Correct |
37 ms |
248 KB |
# of queries: 2553 |
7 |
Correct |
42 ms |
292 KB |
# of queries: 2568 |
8 |
Correct |
40 ms |
376 KB |
# of queries: 2402 |
9 |
Correct |
37 ms |
248 KB |
# of queries: 2512 |
10 |
Correct |
20 ms |
376 KB |
# of queries: 1478 |
11 |
Correct |
2 ms |
248 KB |
# of queries: 0 |
12 |
Correct |
2 ms |
248 KB |
# of queries: 1 |
13 |
Correct |
2 ms |
248 KB |
# of queries: 4 |
14 |
Correct |
2 ms |
376 KB |
# of queries: 7 |
15 |
Correct |
2 ms |
248 KB |
# of queries: 73 |
16 |
Correct |
4 ms |
248 KB |
# of queries: 187 |
17 |
Correct |
410 ms |
248 KB |
# of queries: 18008 |
18 |
Correct |
376 ms |
276 KB |
# of queries: 17231 |
19 |
Correct |
436 ms |
332 KB |
# of queries: 17451 |
20 |
Correct |
369 ms |
376 KB |
# of queries: 16277 |
21 |
Correct |
314 ms |
248 KB |
# of queries: 15362 |
22 |
Correct |
420 ms |
376 KB |
# of queries: 17617 |
23 |
Correct |
368 ms |
328 KB |
# of queries: 17170 |
24 |
Correct |
144 ms |
376 KB |
# of queries: 7885 |
25 |
Correct |
397 ms |
376 KB |
# of queries: 17118 |
26 |
Correct |
356 ms |
412 KB |
# of queries: 15989 |
27 |
Correct |
126 ms |
376 KB |
# of queries: 7994 |
28 |
Correct |
432 ms |
376 KB |
# of queries: 17935 |
29 |
Correct |
429 ms |
332 KB |
# of queries: 17915 |
30 |
Correct |
431 ms |
248 KB |
# of queries: 17935 |