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<int> p={1}; for (int i = 0; i < 25; i++) p.push_back(p.back()*3);
vector<vector<int>> v(25, vector<int>(n+1, 0));
for (int i = 0; i < 25; i++) {
if (i) v[i][0] = !(((i+2)/3)%2);
for (int j = 1; j <= n; j++) {
if (i) {
int d = (j/p[(i+2)/3-1])%3;
if (d > (3-i%3)%3) v[i][j] = -1-!v[i][0];
else if (d < (3-i%3)%3) v[i][j] = -1-(v[i][0]);
else if ((i+2)/3-2 >=0) v[i][j] = ((i+2)/3-1)*3 - (j/p[(i+2)/3-2])%3;
} else {
v[i][j] = 8*3-(j/p[7])%3;
}
}
} 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... |