#include "koala.h"
#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 100;
int moi[MAX_N], adverse[MAX_N], won[MAX_N];
void play() {
playRound(moi, adverse);
for (int i = 0; i < MAX_N; ++i) {
won[i] = (adverse[i] > moi[i]);
}
}
void reset() {
memset(moi, 0, sizeof(moi));
memset(adverse, 0, sizeof(adverse));
memset(won, 0, sizeof(won));
}
int minValue(int N, int W) {
reset();
moi[0] = 1;
play();
for (int i = 0; i < N; ++i) {
if (!won[i]) {
return i;
}
}
}
int maxValue(int N, int W) {
reset();
vector<int> isCand(N, 1);
int cnt = N;
while (cnt > 1) {
reset();
int perPos = N/cnt;
for (int i = 0; i < N; ++i) {
if (isCand[i]) {
moi[i] = perPos;
}
}
play();
cnt = 0;
for (int i = 0; i < N; ++i) {
isCand[i] &= won[i];
cnt += isCand[i];
}
}
int argMax = 0;
while (!isCand[argMax]) ++argMax;
return argMax;
}
int greaterValue(int N, int W) {
reset();
int lo = 1, hi = min(8, W/2);
while (lo <= hi) {
int mid = (lo+hi)/2;
reset();
moi[0] = moi[1] = mid;
play();
if (won[0] > won[1]) return 0;
if (won[0] < won[1]) return 1;
if (!won[0]) hi = mid-1;
else lo = mid+1;
}
return -1;
}
void allValues(int N, int W, int *P) {
reset();
if (W == 2*N) {
// TODO: Implement Subtask 4 solution here.
// You may leave this block unmodified if you are not attempting this
// subtask.
} else {
// TODO: Implement Subtask 5 solution here.
// You may leave this block unmodified if you are not attempting this
// subtask.
}
}
Compilation message
koala.cpp: In function 'int minValue(int, int)':
koala.cpp:29:1: warning: control reaches end of non-void function [-Wreturn-type]
29 | }
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
208 KB |
Output is correct |
2 |
Correct |
3 ms |
208 KB |
Output is correct |
3 |
Correct |
3 ms |
208 KB |
Output is correct |
4 |
Correct |
3 ms |
276 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
208 KB |
Output is correct |
2 |
Correct |
10 ms |
324 KB |
Output is correct |
3 |
Correct |
12 ms |
208 KB |
Output is correct |
4 |
Correct |
11 ms |
208 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
49 ms |
328 KB |
Output is partially correct |
2 |
Partially correct |
59 ms |
324 KB |
Output is partially correct |
3 |
Partially correct |
58 ms |
328 KB |
Output is partially correct |
4 |
Partially correct |
49 ms |
316 KB |
Output is partially correct |
5 |
Partially correct |
48 ms |
328 KB |
Output is partially correct |
6 |
Partially correct |
49 ms |
336 KB |
Output is partially correct |
7 |
Partially correct |
48 ms |
312 KB |
Output is partially correct |
8 |
Partially correct |
57 ms |
328 KB |
Output is partially correct |
9 |
Partially correct |
48 ms |
372 KB |
Output is partially correct |
10 |
Partially correct |
47 ms |
352 KB |
Output is partially correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
208 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
208 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |