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;
int n;
vector<vector<int> > v(32);
int dig(int x, int j) {
for (int i = 0; i < j; i++) x /= 3;
return x % 3;
}
void solve0(int i) {
int x = 7 - (i / 4);
v[i][0] = 0;
for (int j = 1; j <= n; j++) v[i][j] = i + 1 + dig(j, x);
}
void solve(int i) {
int x = 7 - (i / 4), d = i % 4 - 1;
v[i][0] = 1;
for (int j = 1; j <= n; j++) {
if (d == dig(j, x)) v[i][j] = (i + 3 - d) % 32;
else v[i][j] = (d < dig(j, x) ? -1 : -2);
}
}
vector<vector<int> > devise_strategy(int N) {
n = N;
for (int i = 0; i < 32; i++) {
v[i].assign(n + 1, 0);
(i % 4 ? solve(i) : solve0(i));
}
return v;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |