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 <vector>
using namespace std;
typedef vector<int> vi;
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
#define ROF(i,a,b) for(int i=(b)-1; i>=(a); --i)
std::vector<std::vector<int>> devise_strategy(int N) {
vector<vi> v(21, vi(N+1));
v[0][0] = 0;
FOR(j,1,N+1) {
if(j&(1<<9)) v[0][j] = 20;
else v[0][j] = 10;
}
FOR(i,1,11) {
v[i][0] = v[i+10][0] = 1-(i%2);
FOR(j,1,N+1) {
if(j&(1<<(i-1))) {
v[i][j] = -1-(i%2);
if(i>1) v[i+10][j] = (j&(1<<(i-2)))?(10+i-1):(i-1);
else v[i+10][j] = 0; //never used
} else {
v[i+10][j] = -2+(i%2);
if(i>1) v[i][j] = (j&(1<<(i-2)))?(10+i-1):(i-1);
else v[i][j] = 0; //never used
}
}
}
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... |