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 <iostream>
#include <vector>
using namespace std;
vector <vector <int> > sol;
int decide(int number, int s) {
if (number==0) {
if ((s & (1<<12))) return 1;
return 2 + ((s & (1<<11)) > 0);
}
if (number==1) {
if ((s & (1<<12))) return 6;
return -2;
}
number-=2;
int last, cur, type;
type=sol[number+2][0];
last=11-number/2;
if (last==11 && (s & (1<<12))) return -1;
bool l=(s & (1<<last));
if (number%2!=l) {
if (number%2>l) return -1-type;
return -1-!type;
}
cur=last-1;
l=(s & (1<<cur));
if (cur==0) {
if (l) return -1-!type;
return -1-type;
}
return 2+(number/2+1)*2+l;
}
vector<vector<int> > devise_strategy(int N) {
sol.resize(24);
for (int i=0;i<24;i++) {
sol[i].resize(N+1);
if (i==0) sol[i][0]=0;
else if (i==1) sol[i][0]=1;
else sol[i][0]=((i-2)/2+1)%2;
for (int j=1;j<=N;j++) {
sol[i][j]=decide(i,j);
}
}
return sol;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |