# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
628483 | kingmoshe | Prisoner Challenge (IOI22_prison) | C++17 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "prison.h"
#include <vector>
int get_bit_value(int num, int bit_id) {
if (bit_id == 0) {
return num % 2;
}
return get_bit_value(num / 2, bit_id - 1);
}
int get_maximal_bit_id(int num) {
if (num < 2) {
return 1;
}
return 1 + get_maximal_bit_id(num / 2);
}
std::vector<std::vector<int>> devise_strategy(int N) {
int x = 40;
std::vector<std::vector<int>> s(x + 1, std::vector<int>(x + 1));
for (int i = 0; i <= x; i++) {
for (int j = 0; j <= x; j++) {
x[i][j] = 0;
}
}
for (int i = 0; i <= x; i++) {
if (i % 3 == 0) {
s[i][0] = -1;
}
else {
s[i][0] = -2;
}
}
int bit_id = get_maximal_bit_id(N);
for (int i = 0; i <= x; i++) {
bool looking_at_a = false;
if (i % 3 == 0) {
looking_at_a = true;
if (i != 0) {
bit_id -= 1;
}
}
for (int j = 1; j <= N; j++) {
int cur_bit_value = get_bit_value(j, bit_id);
if (looking_at_a) {
s[i][j] = i + 1 + cur_bit_value;
}
else {
int last_bit_value = (i % 3) - 1;
if (last_bit_value != cur_bit_value) {
if (last_bit_value > cur_bit_value) {
s[i][j] = -1;
}
else {
s[i][j] = -2;
}
}
else {
s[i][j] = i + 1;
if (i % 3 == 1) {
s[i][j] += 1;
}
}
}
}
}
return s;
}