# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
836122 | tengiz05 | Catfish Farm (IOI22_fish) | 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.
#include "prison.h"
#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> devise_strategy(int n) {
vector<vector<int>> f(13 * 4, vector<int>(n + 1));
for (int i = 0; i < 13 * 4; i++) {
int num = 8 - (i >> 2);
int A = i & 1;
int res = i >> 1 & 1;
if (A == 0) {
f[i][0] = 0;
for (int j = 1; j <= n; j++) {
int bit = j >> num & 1;
f[i][j] = ((8 - num) << 2) | (bit << 1) | 1;
}
}
if (A == 1) {
f[i][0] = 1;
for (int j = 1; j <= n; j++) {
int bit = j >> num & 1;
if (bit == res) {
f[i][j] = (8 - num + 1) << 2;
} else {
if (res < bit) {
f[i][j] = -1;
} else {
f[i][j] = -2;
}
}
}
}
}
for (int i = 0; i < f.size(); i++) {
for (int j = 0; j <= n; j++) {
if (f[i][j] >= 13 * 4) f[i][j] = 0;
// cout << f[i][j] << " \n"[j == n];
}
}
return f;
}