#include "library.h"
#include <bits/stdc++.h>
#define taskname ""
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define i64 long long
#define isz(x) (int)x.size()
using namespace std;
void Solve(int n)
{
if (n == 1) {
Answer({1});
return;
}
if (n == 2) {
Answer({1, 2});
return;
}
int st = -1;
vector<int> vis(n, 1);
for (int i = 0; i < n; ++i) {
vis[i] = false;
if (Query(vis) == 1) {
st = i;
break;
}
vis[i] = true;
}
vector<int> res = {st + 1};
vector<int> left;
for (int i = 0; i < n; ++i) if (i != st) left.emplace_back(i);
for (int i = 1; i < n; ++i) {
int l = 0, r = isz(left);
while (l + 1 < r) {
int mid = (l + r) >> 1;
int comp1, comp2;
vis.assign(n, 0);
for (int j = l; j < mid; ++j) vis[left[j]] = true;
comp1 = Query(vis); vis[st] = true; comp2 = Query(vis);
if (comp1 == comp2) r = mid;
else l = mid;
}
int nst = left[l];
st = nst; res.emplace_back(st + 1);
left.erase(left.begin() + l);
}
Answer(res);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
12 ms |
344 KB |
# of queries: 2375 |
2 |
Correct |
20 ms |
344 KB |
# of queries: 2409 |
3 |
Correct |
24 ms |
344 KB |
# of queries: 2648 |
4 |
Correct |
26 ms |
344 KB |
# of queries: 2595 |
5 |
Correct |
15 ms |
344 KB |
# of queries: 2508 |
6 |
Correct |
22 ms |
344 KB |
# of queries: 2551 |
7 |
Correct |
23 ms |
344 KB |
# of queries: 2544 |
8 |
Correct |
22 ms |
344 KB |
# of queries: 2420 |
9 |
Correct |
18 ms |
600 KB |
# of queries: 2546 |
10 |
Correct |
11 ms |
344 KB |
# of queries: 1474 |
11 |
Correct |
1 ms |
344 KB |
# of queries: 0 |
12 |
Correct |
0 ms |
344 KB |
# of queries: 0 |
13 |
Correct |
0 ms |
344 KB |
# of queries: 4 |
14 |
Correct |
1 ms |
344 KB |
# of queries: 7 |
15 |
Correct |
1 ms |
344 KB |
# of queries: 77 |
16 |
Correct |
1 ms |
344 KB |
# of queries: 183 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
12 ms |
344 KB |
# of queries: 2375 |
2 |
Correct |
20 ms |
344 KB |
# of queries: 2409 |
3 |
Correct |
24 ms |
344 KB |
# of queries: 2648 |
4 |
Correct |
26 ms |
344 KB |
# of queries: 2595 |
5 |
Correct |
15 ms |
344 KB |
# of queries: 2508 |
6 |
Correct |
22 ms |
344 KB |
# of queries: 2551 |
7 |
Correct |
23 ms |
344 KB |
# of queries: 2544 |
8 |
Correct |
22 ms |
344 KB |
# of queries: 2420 |
9 |
Correct |
18 ms |
600 KB |
# of queries: 2546 |
10 |
Correct |
11 ms |
344 KB |
# of queries: 1474 |
11 |
Correct |
1 ms |
344 KB |
# of queries: 0 |
12 |
Correct |
0 ms |
344 KB |
# of queries: 0 |
13 |
Correct |
0 ms |
344 KB |
# of queries: 4 |
14 |
Correct |
1 ms |
344 KB |
# of queries: 7 |
15 |
Correct |
1 ms |
344 KB |
# of queries: 77 |
16 |
Correct |
1 ms |
344 KB |
# of queries: 183 |
17 |
Correct |
209 ms |
432 KB |
# of queries: 17982 |
18 |
Correct |
202 ms |
436 KB |
# of queries: 17293 |
19 |
Correct |
189 ms |
424 KB |
# of queries: 17467 |
20 |
Correct |
183 ms |
420 KB |
# of queries: 16325 |
21 |
Correct |
186 ms |
420 KB |
# of queries: 15324 |
22 |
Correct |
210 ms |
600 KB |
# of queries: 17669 |
23 |
Correct |
183 ms |
592 KB |
# of queries: 17224 |
24 |
Correct |
67 ms |
420 KB |
# of queries: 7915 |
25 |
Correct |
202 ms |
424 KB |
# of queries: 17136 |
26 |
Correct |
187 ms |
676 KB |
# of queries: 15963 |
27 |
Correct |
106 ms |
344 KB |
# of queries: 8040 |
28 |
Correct |
181 ms |
420 KB |
# of queries: 15957 |
29 |
Correct |
192 ms |
424 KB |
# of queries: 15939 |
30 |
Correct |
178 ms |
424 KB |
# of queries: 15957 |