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;
std::vector<std::vector<int>> devise_strategy(int N) {
int states = 24-1;
vector v(states+1, vector<int>(N+1));
auto get_trit = [&](auto num, auto stelle){
for(int k=0; k<7-stelle; k++){
num /= 3;
}
return num % 3;
};
for(int x=0; x<=states; x++){
int stelle = (x-1)%8;
int o_trit = (x-1)/8;
int is_b = stelle%2;
if(x==0)
v[x][0] = 1;
else
v[x][0] = is_b;
for(int j=0; j<N; j++){
if(x==0){
v[x][j+1] = 1 + 8 * get_trit(j, 0);
}else{
if(get_trit(j, stelle) == o_trit){
int ntrit = get_trit(j, stelle+1);
if(stelle==6 and (ntrit == 0 or ntrit == 2)){
v[x][j+1] = is_b^(ntrit==0) ? -1 : -2;
}else{
v[x][j+1] = 8 * ntrit + stelle + 2;
}
}else{
v[x][j+1] = is_b^(get_trit(j, stelle)<o_trit) ? -1 : -2;
}
}
}
}
for(int i=0; i<=states; i++){
for(int j=0; j<N; j++){
v[i][j] = min(v[i][j], states);
}
}
// redundant (stelle 7, trit 1)
// redundant (stelle 7, trit 2)
/*
for(int i=0; i<v.size(); i++){
for(int j=0; j<v[i].size(); j++)
cout << v[i][j] << " ";
cout << endl;
}
cout << endl;
*/
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... |