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<vector<int>>s(25, vector<int>(N+1));
s[0][0] = 0; //p 0 bag A
for(int j=1; j<=N; ++j) {
if(j >> 12 & 1) {
s[0][j] = 2;
} else {
s[0][j] = 1;
}
}
for(int i=1; i<25; ++i) {
int cbit = 13 - (i + 1) / 2;
if(i & 1) { //off
if(i % 4 == 1) { //A
s[i][0] = 1;
for(int j=1; j<=N; ++j) {
if(j >> cbit & 1) {
s[i][j] = -1;
} else {
if(cbit==1) {
if(j & 1) s[i][j] = -1;
else s[i][j] = -2;
continue;
}
s[i][j] = i + 2 + (j >> (cbit-1) & 1);
}
}
} else { //B
s[i][0] = 0;
for(int j=1; j<=N; ++j) {
if(j >> cbit & 1) {
s[i][j] = -2;
} else {
if(cbit==1) {
if(j & 1) s[i][j] = -2;
else s[i][j] = -1;
continue;
}
s[i][j] = i + 2 + (j >> (cbit-1) & 1);
}
}
}
} else { //on
if(i % 4 == 2) { //A
s[i][0] = 1;
for(int j=1; j<=N; ++j) {
if(j >> cbit & 1) {
if(cbit==1) {
if(j & 1) s[i][j] = -1;
else s[i][j] = -2;
continue;
}
s[i][j] = i + 1 + (j >> (cbit-1) & 1);
} else {
s[i][j] = -2;
}
}
} else { //B
s[i][0] = 0;
for(int j=1; j<=N; ++j) {
if(j >> cbit & 1) {
if(cbit==1) {
if(j & 1) s[i][j] = -2;
else s[i][j] = -1;
continue;
}
s[i][j] = i + 1 + (j >> (cbit-1) & 1);
} else {
s[i][j] = -1;
}
}
}
}
}
for(int i=0; i<25; ++i) {
for(int j=0; j<=N; ++j) {
if(s[i][j]>24) s[i][j] = 0;
}
}
return s;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |