# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1079927 |
2024-08-29T03:34:09 Z |
CDuong |
Library (JOI18_library) |
C++17 |
|
34 ms |
600 KB |
#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({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];
// 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);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
24 ms |
344 KB |
# of queries: 2375 |
2 |
Correct |
13 ms |
344 KB |
# of queries: 2409 |
3 |
Correct |
25 ms |
344 KB |
# of queries: 2648 |
4 |
Correct |
32 ms |
344 KB |
# of queries: 2595 |
5 |
Correct |
19 ms |
344 KB |
# of queries: 2508 |
6 |
Correct |
34 ms |
344 KB |
# of queries: 2551 |
7 |
Correct |
19 ms |
344 KB |
# of queries: 2544 |
8 |
Correct |
18 ms |
344 KB |
# of queries: 2420 |
9 |
Correct |
22 ms |
344 KB |
# of queries: 2546 |
10 |
Correct |
15 ms |
600 KB |
# of queries: 1474 |
11 |
Correct |
1 ms |
344 KB |
# of queries: 0 |
12 |
Incorrect |
0 ms |
344 KB |
Wrong Answer [4] |
13 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
24 ms |
344 KB |
# of queries: 2375 |
2 |
Correct |
13 ms |
344 KB |
# of queries: 2409 |
3 |
Correct |
25 ms |
344 KB |
# of queries: 2648 |
4 |
Correct |
32 ms |
344 KB |
# of queries: 2595 |
5 |
Correct |
19 ms |
344 KB |
# of queries: 2508 |
6 |
Correct |
34 ms |
344 KB |
# of queries: 2551 |
7 |
Correct |
19 ms |
344 KB |
# of queries: 2544 |
8 |
Correct |
18 ms |
344 KB |
# of queries: 2420 |
9 |
Correct |
22 ms |
344 KB |
# of queries: 2546 |
10 |
Correct |
15 ms |
600 KB |
# of queries: 1474 |
11 |
Correct |
1 ms |
344 KB |
# of queries: 0 |
12 |
Incorrect |
0 ms |
344 KB |
Wrong Answer [4] |
13 |
Halted |
0 ms |
0 KB |
- |