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(19, vector<int>(N+1));
s[0][0] = 0; //p 0 bag A
for(int j=1; j<=N; ++j) {
if(j >> 8 & 1) {
s[0][j] = 2;
} else {
s[0][j] = 1;
}
}
for(int i=1; i<19; ++i) {
int cbit = 9 - (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 {
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 {
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) {
s[i][j] = i + 2 + (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) {
s[i][j] = i + 2 + (j >> (cbit-1) & 1);
} else {
s[i][j] = -1;
}
}
}
}
}
for(int i=0; i<19; ++i) {
for(int j=0; j<=N; ++j) {
if(s[i][j]>18) s[i][j] = 0;
}
}
// for(int i=0; i<19; ++i) {
// for(int j=0; j<=N; ++j) {
// cerr<<s[i][j]<<' ';
// }
// cerr<<'\n';
// }
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... |