#include "library.h"
#include <bits/stdc++.h>
using namespace std;
#define REP(i, j, k) for (int i = j; i < k; i++)
#define pb push_back
void Solve(int n) {
vector<int> q(n, 1), res(n, -1), done(n, 0);
int end = -1;
REP (i, 0, n) {
q[i] = 0;
if (Query(q) == 1) {
end = i;
break;
}
q[i] = 1;
}
res[0] = end;
done[end] = 1;
REP (i, 1, n) {
vector<int> useful;
REP (j, 0, n) if (!done[j]) useful.pb(j);
int lo = 0, hi = useful.size() - 1, mid;
while (lo < hi) {
mid = lo + hi + 1 >> 1;
REP (j, 0, n) q[j] = 0;
REP (j, 0, mid) q[useful[j]] = 1;
q[res[i - 1]] = 1;
int with = Query(q);
q[res[i - 1]] = 0;
int without = Query(q);
if (with == without) {
hi = mid - 1;
} else {
lo = mid;
}
}
res[i] = useful[hi];
done[useful[hi]] = 1;
}
REP (i, 0, n) res[i]++;
Answer(res);
}
Compilation message
library.cpp: In function 'void Solve(int)':
library.cpp:26:18: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
26 | mid = lo + hi + 1 >> 1;
| ~~~~~~~~^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
37 ms |
364 KB |
# of queries: 2375 |
2 |
Correct |
36 ms |
364 KB |
# of queries: 2409 |
3 |
Correct |
47 ms |
364 KB |
# of queries: 2648 |
4 |
Correct |
41 ms |
492 KB |
# of queries: 2595 |
5 |
Correct |
39 ms |
364 KB |
# of queries: 2508 |
6 |
Correct |
36 ms |
364 KB |
# of queries: 2551 |
7 |
Correct |
36 ms |
364 KB |
# of queries: 2544 |
8 |
Correct |
41 ms |
364 KB |
# of queries: 2420 |
9 |
Correct |
33 ms |
364 KB |
# of queries: 2546 |
10 |
Correct |
25 ms |
364 KB |
# of queries: 1474 |
11 |
Runtime error |
1 ms |
364 KB |
Execution killed with signal 13 (could be triggered by violating memory limits) |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
37 ms |
364 KB |
# of queries: 2375 |
2 |
Correct |
36 ms |
364 KB |
# of queries: 2409 |
3 |
Correct |
47 ms |
364 KB |
# of queries: 2648 |
4 |
Correct |
41 ms |
492 KB |
# of queries: 2595 |
5 |
Correct |
39 ms |
364 KB |
# of queries: 2508 |
6 |
Correct |
36 ms |
364 KB |
# of queries: 2551 |
7 |
Correct |
36 ms |
364 KB |
# of queries: 2544 |
8 |
Correct |
41 ms |
364 KB |
# of queries: 2420 |
9 |
Correct |
33 ms |
364 KB |
# of queries: 2546 |
10 |
Correct |
25 ms |
364 KB |
# of queries: 1474 |
11 |
Runtime error |
1 ms |
364 KB |
Execution killed with signal 13 (could be triggered by violating memory limits) |
12 |
Halted |
0 ms |
0 KB |
- |