#include "koala.h"
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e2 + 20;
int B[maxn];
int R[maxn];
int tr[maxn * 4];
int minValue(int N, int W) {
// TODO: Implement Subtask 1 solution here.
// You may leave this function unmodified if you are not attempting this
// subtask.
B[0] = 1;
for (int i = 1; i < N; i++) {
B[i] = 0;
}
playRound(B, R);
for (int i = 0; i < N; i++) {
if (R[i] <= B[i]) {
return i;
}
}
return -1;
}
int maxValue(int N, int W) {
// TODO: Implement Subtask 2 solution here.
// You may leave this function unmodified if you are not attempting this
// subtask.
int cnt = N;
for (int i = 0; i < N; i++) {
B[i] = 1;
}
while (cnt > 1) {
for (int i = 0; i < N; i++) {
if (B[i] == 1) {
B[i] = W / cnt;
}
}
playRound(B, R);
cnt = 0;
for (int i = 0; i < N; i++) {
B[i] = (B[i] > 0 && R[i] > B[i]);
cnt += B[i];
}
}
for (int i = 0; i < N; i++) {
if (B[i] == 1) {
return i;
}
}
return -1;
}
int greaterValue(int N, int W, int x, int y) {
// TODO: Implement Subtask 3 solution here.
// You may leave this function unmodified if you are not attempting this
// subtask.
vector<int> vals = {2, 4, 8};
for (auto v: vals) {
for (int i = 0; i < N; i++) {
B[i] = 0;
}
B[x] = v;
B[y] = v;
playRound(B, R);
if ((R[x] > B[x]) != (R[y] > B[y])) {
if (R[x] > B[x]) {
return x;
}
else {
return y;
}
}
else {
if (v == 2 && R[x] <= B[x]) {
return minValue(N, W) ^ (x ^ y);
}
}
}
return -1;
}
int greaterValue(int N, int W) {
return greaterValue(N, W, 0, 1);
}
int merge(int N, int W, int x, int y) {
if (x == -1) {
return y;
}
else if (y == -1) {
return x;
}
else {
return greaterValue(N, W, x, y);
}
}
void build(int N, int W, int id, int lt, int rt) {
if (lt == rt) {
tr[id] = lt - 1;
return;
}
int mt = (lt + rt) / 2;
build(N, W, id * 2, lt, mt);
build(N, W, id * 2 + 1, mt + 1, rt);
tr[id] = merge(N, W, tr[id * 2], tr[id * 2 + 1]);
}
void update(int N, int W, int id, int lt, int rt, int pos) {
if (lt == rt) {
tr[id] = -1;
return;
}
int mt = (lt + rt) / 2;
if (pos <= mt) {
update(N, W, id * 2, lt, mt, pos);
}
else {
update(N, W, id * 2 + 1, mt + 1, rt, pos);
}
tr[id] = merge(N, W, tr[id * 2], tr[id * 2 + 1]);
}
void allValues(int N, int W, int *P) {
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.
build(N, W, 1, 1, N);
for (int i = N; i >= 1; i--) {
P[tr[1]] = i;
if (i == 1) {
break;
}
update(N, W, 1, 1, N, tr[1] + 1);
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
208 KB |
Output is correct |
2 |
Correct |
5 ms |
324 KB |
Output is correct |
3 |
Correct |
5 ms |
320 KB |
Output is correct |
4 |
Correct |
4 ms |
208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
13 ms |
208 KB |
Output is correct |
2 |
Correct |
15 ms |
316 KB |
Output is correct |
3 |
Correct |
18 ms |
320 KB |
Output is correct |
4 |
Correct |
15 ms |
208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
92 ms |
336 KB |
Output is correct |
2 |
Correct |
86 ms |
324 KB |
Output is correct |
3 |
Correct |
97 ms |
324 KB |
Output is correct |
4 |
Correct |
84 ms |
328 KB |
Output is correct |
5 |
Correct |
83 ms |
436 KB |
Output is correct |
6 |
Correct |
89 ms |
328 KB |
Output is correct |
7 |
Correct |
86 ms |
320 KB |
Output is correct |
8 |
Correct |
81 ms |
328 KB |
Output is correct |
9 |
Correct |
87 ms |
328 KB |
Output is correct |
10 |
Correct |
94 ms |
440 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
208 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
30 ms |
208 KB |
Output is partially correct |
2 |
Partially correct |
44 ms |
296 KB |
Output is partially correct |
3 |
Partially correct |
43 ms |
296 KB |
Output is partially correct |
4 |
Partially correct |
47 ms |
292 KB |
Output is partially correct |
5 |
Partially correct |
45 ms |
292 KB |
Output is partially correct |
6 |
Partially correct |
49 ms |
300 KB |
Output is partially correct |
7 |
Partially correct |
49 ms |
296 KB |
Output is partially correct |
8 |
Partially correct |
36 ms |
208 KB |
Output is partially correct |
9 |
Partially correct |
40 ms |
296 KB |
Output is partially correct |
10 |
Partially correct |
39 ms |
208 KB |
Output is partially correct |
11 |
Partially correct |
40 ms |
296 KB |
Output is partially correct |
12 |
Partially correct |
45 ms |
296 KB |
Output is partially correct |
13 |
Partially correct |
51 ms |
300 KB |
Output is partially correct |
14 |
Partially correct |
43 ms |
292 KB |
Output is partially correct |
15 |
Partially correct |
46 ms |
300 KB |
Output is partially correct |
16 |
Partially correct |
40 ms |
296 KB |
Output is partially correct |
17 |
Partially correct |
47 ms |
292 KB |
Output is partially correct |
18 |
Partially correct |
41 ms |
208 KB |
Output is partially correct |
19 |
Partially correct |
41 ms |
208 KB |
Output is partially correct |
20 |
Partially correct |
42 ms |
300 KB |
Output is partially correct |
21 |
Partially correct |
41 ms |
208 KB |
Output is partially correct |
22 |
Partially correct |
40 ms |
208 KB |
Output is partially correct |
23 |
Partially correct |
38 ms |
296 KB |
Output is partially correct |
24 |
Partially correct |
42 ms |
296 KB |
Output is partially correct |
25 |
Partially correct |
57 ms |
300 KB |
Output is partially correct |
26 |
Partially correct |
44 ms |
296 KB |
Output is partially correct |
27 |
Partially correct |
50 ms |
300 KB |
Output is partially correct |
28 |
Partially correct |
40 ms |
308 KB |
Output is partially correct |
29 |
Partially correct |
37 ms |
208 KB |
Output is partially correct |
30 |
Partially correct |
38 ms |
208 KB |
Output is partially correct |
31 |
Partially correct |
39 ms |
208 KB |
Output is partially correct |
32 |
Partially correct |
49 ms |
208 KB |
Output is partially correct |
33 |
Partially correct |
42 ms |
208 KB |
Output is partially correct |
34 |
Partially correct |
48 ms |
296 KB |
Output is partially correct |
35 |
Partially correct |
39 ms |
208 KB |
Output is partially correct |
36 |
Partially correct |
34 ms |
208 KB |
Output is partially correct |
37 |
Partially correct |
38 ms |
328 KB |
Output is partially correct |
38 |
Partially correct |
47 ms |
208 KB |
Output is partially correct |
39 |
Partially correct |
38 ms |
208 KB |
Output is partially correct |
40 |
Partially correct |
36 ms |
208 KB |
Output is partially correct |