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 <bits/stdc++.h>
#include "prison.h"
using namespace std;
typedef long long ll;
int n;
vector<vector<int>> devise_strategy(int N) {
n = N;
int x = 31;
vector<vector<int>> res(x+1, vector<int>(n+1));
for (int i = 0; i <= x; i++) {
bool checkA = i%4 == 0;
int pos = 7-(i/4);
int k = (int)pow(3, pos);
res[i][0] = !checkA;
if (checkA) {
for (int j = 1; j <= n; j++) {
res[i][j] = i + (j/k)%3 + 1;
}
}
else {
for (int j = 1; j <= n; j++) {
int b = (j/k)%3;
if (b != i%4-1) {
res[i][j] = b < i%4-1 ? -2 : -1;
continue;
}
res[i][j] = (i/4+1)*4;
if (res[i][j] > x) res[i][j] = 0;
}
}
}
return res;
}
#ifdef TEST
#include "grader.cpp"
#endif
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |