#include <bits/stdc++.h>
#include "koala.h"
int minValue(int n, int w) {
int query[n];
for (int i = 0; i < n; i++) query[i] = !i;
int response[n];
playRound(query, response);
for (int i = 0; i < n; i++) if (response[i] <= query[i]) return i;
assert(0);
}
std::random_device rnd_dev;
std::mt19937 rnd(rnd_dev() ^ clock());
int maxValue(int n, int w) {
std::vector<int> cands(n);
std::iota(cands.begin(), cands.end(), 0);
std::shuffle(cands.begin(), cands.end(), rnd);
while (cands.size() >= 8) {
int one = w / cands.size();
int query[n];
memset(query, 0, sizeof(query));
for (auto i : cands) query[i] = one;
int response[n];
playRound(query, response);
std::vector<int> next;
for (auto i : cands) if (response[i] > query[i]) next.push_back(i);
assert(next.size());
cands = next;
}
return cands[0];
}
int greaterValue(int n, int w) {
auto go = [&] (int k) {
int query[n];
memset(query, 0, sizeof(query));
query[0] = query[1] = k - 1;
int response[n];
playRound(query, response);
if ((query[0] < response[0]) < (query[1] < response[1])) return 1;
if ((query[0] < response[0]) > (query[1] < response[1])) return 0;
if (query[0] < response[0]) return -1;
return -2;
};
int t = go(2);
if (t >= 0) return t;
if (t == -1) {
t = go(5);
if (t >= 0) return t;
if (t == -1) {
t = go(9);
if (t >= 0) return t;
assert(0);
} else {
t = go(3);
if (t >= 0) return t;
assert(0);
}
} else {
int query[n];
for (auto &i : query) i = 1;
int response[n];
playRound(query, response);
int tmp = -1;
for (int i = 0; i < n; i++) if (response[i] > query[i]) tmp = i;
memset(query, 0, sizeof(query));
query[tmp] = 1;
playRound(query, response);
int r0 = -1;
for (int i = 0; i < n; i++) if (response[i] <= query[i]) r0 = i;
query[tmp] = 2;
playRound(query, response);
int r1 = -1;
for (int i = 0; i < n; i++) if (r0 != i && response[i] <= query[i]) r1 = i;
if (r0 == 0) return 1;
if (r0 == 1) return 0;
if (r1 == 0) return 1;
if (r1 == 1) return 0;
assert(0);
}
}
void allValues(int n, int w, int *p) {
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
200 KB |
Output is correct |
2 |
Correct |
6 ms |
200 KB |
Output is correct |
3 |
Correct |
5 ms |
200 KB |
Output is correct |
4 |
Correct |
4 ms |
200 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
17 ms |
200 KB |
Output is correct |
2 |
Correct |
15 ms |
320 KB |
Output is correct |
3 |
Correct |
19 ms |
320 KB |
Output is correct |
4 |
Correct |
15 ms |
200 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
100 ms |
328 KB |
Output is correct |
2 |
Correct |
98 ms |
324 KB |
Output is correct |
3 |
Correct |
100 ms |
328 KB |
Output is correct |
4 |
Correct |
97 ms |
324 KB |
Output is correct |
5 |
Correct |
107 ms |
332 KB |
Output is correct |
6 |
Correct |
103 ms |
328 KB |
Output is correct |
7 |
Correct |
98 ms |
336 KB |
Output is correct |
8 |
Correct |
99 ms |
320 KB |
Output is correct |
9 |
Correct |
99 ms |
320 KB |
Output is correct |
10 |
Correct |
103 ms |
328 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
200 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
200 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |