#include "koala.h"
#include <string.h>
#define N 100
int minValue(int n, int w) {
static int bb[N], rr[N];
int i;
memset(bb, 0, n * sizeof *bb), bb[0] = 1;
playRound(bb, rr);
for (i = 1; i < n; i++)
if (rr[i] == 0)
return i;
return 0;
}
int aa[][3] = { { 2, 4, 11 }, { 2, 4, 6 }, { 2, 4, 0 }, { 2, 0, 0 }, { 0, 0, 0 } };
int kk[] = { 3, 3, 2, 1, 0 };
char used[N];
int maxValue(int n, int w) {
static int bb[N], rr[N];
int g, i, r, cnt;
if (n >= 44)
g = 0;
else if (n >= 20)
g = 1;
else if (n >= 8)
g = 2;
else if (n >= 4)
g = 3;
else if (n >= 2)
g = 4;
else {
for (i = 0; i < N; i++)
if (!used[i])
return i;
return -1;
}
for (i = 0; i < N; i++)
bb[i] = !used[i];
playRound(bb, rr);
for (r = 0; r < kk[g]; r++) {
for (i = 0; i < N; i++)
if (bb[i] && rr[i])
bb[i] = aa[g][r];
else
bb[i] = 0;
playRound(bb, rr);
}
cnt = 0;
for (i = 0; i < N; i++)
if (bb[i] && rr[i])
cnt++;
for (i = 0; i < N; i++)
if (bb[i] && rr[i])
return i;
return -1;
}
int greaterValue(int n, int w) {
// TODO: Implement Subtask 3 solution here.
// You may leave this function unmodified if you are not attempting this
// subtask.
return 0;
}
int n_;
int compare(int i, int j) {
static int bb[N], rr[N];
memset(bb, 0, n_ * sizeof *bb);
bb[i] = bb[j] = n_;
playRound(bb, rr);
return rr[i] > bb[i] ? 1 : -1;
}
void sort(int *ii, int l, int r) {
static int jj[N];
int m, i, j, k;
if (r - l == 1)
return;
m = (l + r) / 2;
sort(ii, l, m), sort(ii, m, r);
i = l, j = m, k = l;
while (i < m && j < r)
jj[k++] = compare(ii[i], ii[j]) < 0 ? ii[i++] : ii[j++];
while (i < m)
jj[k++] = ii[i++];
while (j < r)
jj[k++] = ii[j++];
memcpy(ii + l, jj + l, (r - l) * sizeof *jj);
}
void allValues(int n, int w, int *pp) {
static int ii[N];
if (w == n * 2) {
int i;
for (i = 0; i < n; i++)
ii[i] = i;
n_ = n, sort(ii, 0, n);
for (i = 0; i < n; i++)
pp[ii[i]] = i + 1;
} else {
int p;
for (p = n; p >= 1; p--) {
int i = maxValue(p, p);
used[i] = 1, pp[i] = p;
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
364 KB |
Output is correct |
2 |
Correct |
7 ms |
364 KB |
Output is correct |
3 |
Correct |
6 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
20 ms |
364 KB |
Output is correct |
2 |
Correct |
17 ms |
364 KB |
Output is correct |
3 |
Correct |
18 ms |
364 KB |
Output is correct |
4 |
Correct |
17 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
26 ms |
364 KB |
Output is correct |
2 |
Correct |
46 ms |
492 KB |
Output is correct |
3 |
Correct |
47 ms |
492 KB |
Output is correct |
4 |
Correct |
46 ms |
364 KB |
Output is correct |
5 |
Correct |
44 ms |
364 KB |
Output is correct |
6 |
Correct |
43 ms |
364 KB |
Output is correct |
7 |
Correct |
45 ms |
492 KB |
Output is correct |
8 |
Correct |
45 ms |
500 KB |
Output is correct |
9 |
Correct |
47 ms |
492 KB |
Output is correct |
10 |
Correct |
42 ms |
364 KB |
Output is correct |
11 |
Correct |
43 ms |
364 KB |
Output is correct |
12 |
Correct |
32 ms |
364 KB |
Output is correct |
13 |
Correct |
43 ms |
364 KB |
Output is correct |
14 |
Correct |
42 ms |
364 KB |
Output is correct |
15 |
Correct |
43 ms |
364 KB |
Output is correct |
16 |
Correct |
39 ms |
364 KB |
Output is correct |
17 |
Correct |
38 ms |
356 KB |
Output is correct |
18 |
Correct |
43 ms |
364 KB |
Output is correct |
19 |
Correct |
41 ms |
376 KB |
Output is correct |
20 |
Correct |
40 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
16 ms |
364 KB |
Output is partially correct |
2 |
Partially correct |
17 ms |
364 KB |
Output is partially correct |
3 |
Partially correct |
15 ms |
364 KB |
Output is partially correct |
4 |
Partially correct |
16 ms |
492 KB |
Output is partially correct |
5 |
Partially correct |
15 ms |
364 KB |
Output is partially correct |
6 |
Partially correct |
15 ms |
364 KB |
Output is partially correct |
7 |
Partially correct |
16 ms |
364 KB |
Output is partially correct |
8 |
Partially correct |
18 ms |
364 KB |
Output is partially correct |
9 |
Partially correct |
16 ms |
492 KB |
Output is partially correct |
10 |
Partially correct |
17 ms |
512 KB |
Output is partially correct |
11 |
Partially correct |
17 ms |
364 KB |
Output is partially correct |
12 |
Partially correct |
14 ms |
364 KB |
Output is partially correct |
13 |
Partially correct |
15 ms |
364 KB |
Output is partially correct |
14 |
Partially correct |
15 ms |
364 KB |
Output is partially correct |
15 |
Partially correct |
15 ms |
364 KB |
Output is partially correct |
16 |
Partially correct |
15 ms |
364 KB |
Output is partially correct |
17 |
Partially correct |
15 ms |
364 KB |
Output is partially correct |
18 |
Partially correct |
15 ms |
364 KB |
Output is partially correct |
19 |
Partially correct |
18 ms |
364 KB |
Output is partially correct |
20 |
Partially correct |
17 ms |
384 KB |
Output is partially correct |
21 |
Partially correct |
15 ms |
364 KB |
Output is partially correct |
22 |
Partially correct |
15 ms |
364 KB |
Output is partially correct |
23 |
Partially correct |
15 ms |
364 KB |
Output is partially correct |
24 |
Partially correct |
15 ms |
364 KB |
Output is partially correct |
25 |
Partially correct |
15 ms |
376 KB |
Output is partially correct |
26 |
Partially correct |
15 ms |
364 KB |
Output is partially correct |
27 |
Partially correct |
15 ms |
364 KB |
Output is partially correct |
28 |
Partially correct |
15 ms |
364 KB |
Output is partially correct |
29 |
Partially correct |
18 ms |
364 KB |
Output is partially correct |
30 |
Partially correct |
17 ms |
364 KB |
Output is partially correct |
31 |
Partially correct |
18 ms |
492 KB |
Output is partially correct |
32 |
Partially correct |
15 ms |
364 KB |
Output is partially correct |
33 |
Partially correct |
15 ms |
364 KB |
Output is partially correct |
34 |
Partially correct |
15 ms |
364 KB |
Output is partially correct |
35 |
Partially correct |
15 ms |
364 KB |
Output is partially correct |
36 |
Partially correct |
15 ms |
364 KB |
Output is partially correct |
37 |
Partially correct |
16 ms |
364 KB |
Output is partially correct |
38 |
Partially correct |
15 ms |
364 KB |
Output is partially correct |
39 |
Partially correct |
17 ms |
364 KB |
Output is partially correct |
40 |
Partially correct |
15 ms |
364 KB |
Output is partially correct |