#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)
{
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];
// cout << nst << endl;
st = nst; res.emplace_back(st + 1);
left.erase(left.begin() + l);
}
// for (auto val : res) cout << val + 1 << " ";
// cout << endl;
Answer(res);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
15 ms |
344 KB |
# of queries: 2375 |
2 |
Correct |
25 ms |
344 KB |
# of queries: 2409 |
3 |
Correct |
22 ms |
344 KB |
# of queries: 2648 |
4 |
Correct |
14 ms |
344 KB |
# of queries: 2595 |
5 |
Correct |
22 ms |
344 KB |
# of queries: 2508 |
6 |
Correct |
31 ms |
344 KB |
# of queries: 2551 |
7 |
Correct |
25 ms |
600 KB |
# of queries: 2544 |
8 |
Correct |
18 ms |
344 KB |
# of queries: 2420 |
9 |
Correct |
13 ms |
344 KB |
# of queries: 2546 |
10 |
Correct |
10 ms |
344 KB |
# of queries: 1474 |
11 |
Runtime error |
0 ms |
344 KB |
Execution killed with signal 13 |
12 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
15 ms |
344 KB |
# of queries: 2375 |
2 |
Correct |
25 ms |
344 KB |
# of queries: 2409 |
3 |
Correct |
22 ms |
344 KB |
# of queries: 2648 |
4 |
Correct |
14 ms |
344 KB |
# of queries: 2595 |
5 |
Correct |
22 ms |
344 KB |
# of queries: 2508 |
6 |
Correct |
31 ms |
344 KB |
# of queries: 2551 |
7 |
Correct |
25 ms |
600 KB |
# of queries: 2544 |
8 |
Correct |
18 ms |
344 KB |
# of queries: 2420 |
9 |
Correct |
13 ms |
344 KB |
# of queries: 2546 |
10 |
Correct |
10 ms |
344 KB |
# of queries: 1474 |
11 |
Runtime error |
0 ms |
344 KB |
Execution killed with signal 13 |
12 |
Halted |
0 ms |
0 KB |
- |