# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
629094 | daria | Prisoner Challenge (IOI22_prison) | C++17 | 6 ms | 648 KiB |
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 "bits/stdc++.h"
#include "prison.h"
using namespace std;
#define ll int
vector<vector<int> > devise_strategy(int N) {
vector<vector<int> > s(24, vector<int>(N+1, 0));
int v[6][4], mp[24], mp2[24], c = 1;
for(int i=0; i<6; ++i){
for(int j=0; j<4; ++j){
if(i == 0 && j == 3){
v[i][j] = 0;
} else{
mp[c] = j;
v[i][j] = c++;
}
}
}
int ans[2] = {-1, -2};
s[0][0] = 1;
for(int j=1; j<=N; ++j){
int bit = (j >> 11)%4;
s[0][j] = v[0][bit];
}
for(int i=1; i<24; ++i){
int k = i/4;
s[i][0] = k%2;
for(int j=1; j<=N; ++j){
int pow = (1 << (11-2*k));
int bit = (j/pow)%4;
if(bit > mp[i]) s[i][j] = ans[1-k%2];
if(bit < mp[i]) s[i][j] = ans[k%2];
if(bit == mp[i]){
if(k<5) s[i][j] = v[k+1][(j >> (9-2*k))%4];
else if(j%2) s[i][j] = ans[1-k%2];
else s[i][j] = ans[k%2];
}
if(j <= k+1) s[i][j] = ans[k%2];
if(j >= N-k) s[i][j] = ans[1-k%2];
if(j%pow == 0) s[i][j] = ans[k%2];
if(j%pow == pow-1) s[i][j] = ans[1-k%2];
}
}
return s;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |