#include <bits/stdc++.h>
#include "library.h"
using namespace std;
void Solve(int N) {
vector<int> a(N, 1);
vector<int> ans;
set<int> st;
for (int i = 1; i <= N; i++) {
st.insert(i);
}
for (int i = 1; i <= N; i++) {
a[i - 1] = 0;
if (Query(a) == 1) {
ans.push_back(i);
st.erase(i);
break;
}
a[i - 1] = 1;
}
for (int t = 0; t < N - 1; t++) {
vector<int> b;
for (auto& x : st) {
b.push_back(x);
}
int l = 0, r = (int) b.size() - 1;
while (l < r) {
int mid = (l + r) / 2;
a.assign(N, 0);
for (int i = l; i <= mid; i++) {
a[b[i] - 1] = 1;
}
int tmp1 = Query(a);
a[ans.back() - 1] = 1;
int tmp2 = Query(a);
if (tmp1 < tmp2) {
l = mid + 1;
} else {
r = mid;
}
}
ans.push_back(b[l]);
st.erase(b[l]);
}
Answer(ans);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
41 ms |
384 KB |
# of queries: 2387 |
2 |
Correct |
50 ms |
376 KB |
# of queries: 2433 |
3 |
Correct |
45 ms |
384 KB |
# of queries: 2638 |
4 |
Correct |
45 ms |
384 KB |
# of queries: 2593 |
5 |
Correct |
47 ms |
384 KB |
# of queries: 2504 |
6 |
Correct |
33 ms |
384 KB |
# of queries: 2553 |
7 |
Correct |
47 ms |
384 KB |
# of queries: 2568 |
8 |
Correct |
43 ms |
384 KB |
# of queries: 2402 |
9 |
Correct |
47 ms |
384 KB |
# of queries: 2512 |
10 |
Correct |
26 ms |
384 KB |
# of queries: 1478 |
11 |
Incorrect |
4 ms |
384 KB |
Wrong Answer [2] |
12 |
Correct |
5 ms |
256 KB |
# of queries: 1 |
13 |
Correct |
4 ms |
256 KB |
# of queries: 4 |
14 |
Correct |
5 ms |
384 KB |
# of queries: 7 |
15 |
Correct |
6 ms |
256 KB |
# of queries: 73 |
16 |
Correct |
8 ms |
384 KB |
# of queries: 187 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
41 ms |
384 KB |
# of queries: 2387 |
2 |
Correct |
50 ms |
376 KB |
# of queries: 2433 |
3 |
Correct |
45 ms |
384 KB |
# of queries: 2638 |
4 |
Correct |
45 ms |
384 KB |
# of queries: 2593 |
5 |
Correct |
47 ms |
384 KB |
# of queries: 2504 |
6 |
Correct |
33 ms |
384 KB |
# of queries: 2553 |
7 |
Correct |
47 ms |
384 KB |
# of queries: 2568 |
8 |
Correct |
43 ms |
384 KB |
# of queries: 2402 |
9 |
Correct |
47 ms |
384 KB |
# of queries: 2512 |
10 |
Correct |
26 ms |
384 KB |
# of queries: 1478 |
11 |
Incorrect |
4 ms |
384 KB |
Wrong Answer [2] |
12 |
Correct |
5 ms |
256 KB |
# of queries: 1 |
13 |
Correct |
4 ms |
256 KB |
# of queries: 4 |
14 |
Correct |
5 ms |
384 KB |
# of queries: 7 |
15 |
Correct |
6 ms |
256 KB |
# of queries: 73 |
16 |
Correct |
8 ms |
384 KB |
# of queries: 187 |
17 |
Correct |
548 ms |
384 KB |
# of queries: 18008 |
18 |
Correct |
526 ms |
384 KB |
# of queries: 17231 |
19 |
Correct |
485 ms |
424 KB |
# of queries: 17451 |
20 |
Correct |
391 ms |
384 KB |
# of queries: 16277 |
21 |
Correct |
403 ms |
384 KB |
# of queries: 15362 |
22 |
Correct |
452 ms |
384 KB |
# of queries: 17617 |
23 |
Correct |
438 ms |
384 KB |
# of queries: 17170 |
24 |
Correct |
155 ms |
384 KB |
# of queries: 7885 |
25 |
Correct |
453 ms |
384 KB |
# of queries: 17118 |
26 |
Correct |
385 ms |
384 KB |
# of queries: 15989 |
27 |
Correct |
148 ms |
384 KB |
# of queries: 7994 |
28 |
Correct |
505 ms |
384 KB |
# of queries: 17935 |
29 |
Correct |
504 ms |
384 KB |
# of queries: 17915 |
30 |
Correct |
460 ms |
424 KB |
# of queries: 17935 |