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;
bool yeah = true;
int calc(int a, int x) {
a--;
int r = 4999;
yeah = true;
for(int i = 0; i <= x; i++) {
if(a == 0) {
yeah = false;
return -1;
}
else if(a == r) {
yeah = false;
return 3;
}
r = ((r-1)/3);
a--;
a%=r;
}
if(a == 0) {
yeah = false;
}
else if(a == r) {
yeah = false;
}
return a/r;
}
vector<vector<int>> devise_strategy(int n) {
vector<vector<int>> ans(22,vector<int> (n+1));
ans[0][0] = 0;
for(int i = 1; i <= n; i++) {
if(i == 1) {
ans[0][i] = -1;
}
else if(i == n) {
ans[0][i] = -2;
}
else {
ans[0][i] = calc(i,0)+1;
}
}
for(int i = 1; i <= 20; i++) {
int c = (i-1)/3+1;
ans[i][0] = c%2;
for(int j = 1; j <= n; j++) {
if(calc(j,c-1) == (i-1)%3 && yeah) {
ans[i][j] = c*3+calc(j,c)+1;
}
else {
if(yeah) {
if(calc(j,c) == -1) {
if(c%2) {
ans[i][j] = -2;
}
else {
ans[i][j] = -1;
}
}
else {
if(c%2) {
ans[i][j] = -1;
}
else {
ans[i][j] = -2;
}
}
continue;
}
if(calc(j,c-1) < (i-1)%3) {
if(c%2) {
ans[i][j] = -2;
}
else {
ans[i][j] = -1;
}
}
else {
if(c%2) {
ans[i][j] = -1;
}
else {
ans[i][j] = -2;
}
}
}
}
}
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... |