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 calc(int a, int b) {
for(int i = 0; i < b; i++) {
a/=3;
}
return a%3;
}
std::vector<std::vector<int>> devise_strategy(int n) {
vector<vector<int>> ans(0);
for(int i = 0; i < 32; i++) {
ans.push_back(vector<int> (n+1));
}
for(int i = 0; i < 32; i++) {
if(i%4 == 0) {
ans[i][0] = 0;
}
else {
ans[i][0] = 1;
}
int d = 7-(i/4);
for(int j = 1; j <= n; j++) {
if(i%4 == 0) {
ans[i][j] = i+1;
ans[i][j]+=calc(j,d);
}
else {
int x = calc(j,d),y = (i%4)-1;
if(x == y) {
ans[i][j] = min(31,i-(i%4)+4);
}
else if(x < y) {
ans[i][j] = -2;
}
else {
ans[i][j] = -1;
}
}
}
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |