# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1074059 | shmax | Prisoner Challenge (IOI22_prison) | C++17 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
//
// Created by maksym on 8/11/24.
//
#include "prison.h"
#include <bits/stdc++.h>
using namespace std;
#define bit(x, i) ((x >> (i)) & 1)
const int C = 13;
template<typename T>
using vec = vector<T>;
std::vector<std::vector<int>> devise_strategy(int N) {
int x = 2 * C;
vec<vec<int>> s(x + 1, vec<int>(N + 1));
for (int i = 0; i <= x; i++) {
if (i == 0) {
s[i][0] = 1;
for (int j = 1; j <= N; j++) {
s[i][j] = bit(j, C - 1) * C + C;
}
continue;
}
{
int bit_pos = (i - 1) % C;
bool is = i > C;
s[i][0] = bit_pos % 2;
for (int j = 1; j <= N; j++) {
if (is and !bit(j, bit_pos)) {
s[i][j] = -(s[i][0] + 1);
} else if (!is and bit(j, bit_pos)) {
s[i][j] = -((s[i][0] ^ 1) + 1);
} else {
s[i][j] = bit(j, bit_pos-1) * C + bit_pos;
}
}
continue;
}
}
return s;
}