#include "prison.h"
#include <vector>
std::vector<std::vector<int>> devise_strategy(int N) {
using namespace std;
vector<vector<int>> strat(24, vector<int>(N + 1, 0));
strat[0][0] = 0;
for (int i = 0; i < N; ++i) {
strat[0][i + 1] = ((i + 1) >> 11) + 1;
}
strat[1][0] = strat[2][0] = strat[3][0] = 1;
for (int i = 1; i < 4; ++i) {
for (int j = 0; j < N; ++j) {
if ((j + 1) >> 11 == i - 1) {
strat[i][j + 1] = 4 + (((j + 1) >> 10) % 2);
} else if ((j + 1) >> 11 > i - 1) strat[i][j + 1] = -1;
else strat[i][j + 1] = -2;
}
}
for (int i = 0; i < 8; ++i) {
strat[4 + 2 * i][0] = strat[5 + 2 * i][0] = i % 2;
for (int j = 0; j < N; ++j) {
if (((j + 1) >> (10 - i)) % 2 == 0) {
strat[5 + 2 * i][j + 1] = -1 - (i) % 2;
strat[4 + 2 * i][j + 1] = 6 + 2 * i + ((j + 1) >> (9 - i)) % 2;
} else {
strat[4 + 2 * i][j + 1] = -1 - (i + 1) % 2;
strat[5 + 2 * i][j + 1] = 6 + 2 * i + ((j + 1) >> (9 - i)) % 2;
}
}
}
strat[20][0] = strat[21][0] = 0;
for (int i = 0; i < N; ++i) {
if (((i + 1) >> 2) % 2 == 0) {
strat[21][i + 1] = -1;
if (i % 4 == 3) {
strat[20][i + 1] = -1;
} else if (i % 4 == 2) {
strat[20][i + 1] = -2;
} else {
strat[20][i + 1] = 22 + i % 2;
}
} else {
strat[20][i + 1] = -2;
if (i % 4 == 3) {
strat[21][i + 1] = -1;
} else if (i % 4 == 2) {
strat[21][i + 1] = -2;
} else {
strat[21][i + 1] = 22 + i % 2;
}
}
}
strat[22][0] = strat[23][0] = 1;
for (int i = 0; i < N; ++i) {
strat[22][i + 1] = -1 - (((i + 1) % 4) < 1);
strat[23][i + 1] = -1 - (((i + 1) % 4) < 2);
}
return strat;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
2 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
2 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Partially correct |
0 ms |
348 KB |
Output is partially correct |
3 |
Partially correct |
0 ms |
348 KB |
Output is partially correct |
4 |
Partially correct |
4 ms |
604 KB |
Output is partially correct |
5 |
Partially correct |
7 ms |
936 KB |
Output is partially correct |
6 |
Partially correct |
9 ms |
1112 KB |
Output is partially correct |
7 |
Partially correct |
9 ms |
1116 KB |
Output is partially correct |
8 |
Partially correct |
1 ms |
344 KB |
Output is partially correct |
9 |
Partially correct |
1 ms |
348 KB |
Output is partially correct |
10 |
Partially correct |
2 ms |
348 KB |
Output is partially correct |
11 |
Partially correct |
4 ms |
860 KB |
Output is partially correct |
12 |
Partially correct |
7 ms |
860 KB |
Output is partially correct |