# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
627223 | movl228 | Prisoner Challenge (IOI22_prison) | C++17 | 5 ms | 724 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 "prison.h"
#include <bits/stdc++.h>
using namespace std;
vector <vector <int> > devise_strategy(int N){
vector <vector <int> > ans;
for (int i=0; i<=22; i++){
ans.push_back({});
for (int j=0; j<=N; j++) ans.back().push_back(0);
}
for (int i=0; i<=22; i++){
for (int j=0; j<=N; j++){
if (!j){
if (!i||i>=4&&i<=6||i>=10&&i<=12||i>=16&&i<=18) ans[i][j]=0;
else ans[i][j]=1;
} else if (!i){
ans[i][j]=(j-1)/1944+1;
} else if (i<=3){
int th=(j-1)/1944+1;
if (i<th) ans[i][j]=-1;
else if (i>th) ans[i][j]=-2;
else ans[i][j]=(j-1)/648%3+4;
} else if (i<=6){
int th=(j-1)/648+4;
if (i<th) ans[i][j]=-2;
else if (i>th) ans[i][j]=-1;
else ans[i][j]=(j-1)/216%3+7;
} else if (i<=9){
int th=(j-1)/216%3+7;
if (i<th) ans[i][j]=-1;
else if (i>th) ans[i][j]=-2;
else ans[i][j]=(j-1)/72%3+10;
} else if (i<=12){
int th=(j-1)/72%3+10;
if (i<th) ans[i][j]=-2;
else if (i>th) ans[i][j]=-1;
else ans[i][j]=(j-1)/24%3+13;
} else if (i<=15){
int th=(j-1)/24%3+13;
if (i<th) ans[i][j]=-1;
else if (i>th) ans[i][j]=-2;
else ans[i][j]=(j-1)/8%3+16;
} else if (i<=18){
int th=(j-1)/8%3+16;
if (i<th) ans[i][j]=-2;
else if (i>th) ans[i][j]=-1;
else ans[i][j]=(j-1)/2%4+19;
} else if (i<=22){
int th=(j-1)/2%4+19;
if (i<th) ans[i][j]=-1;
else if (i>th) ans[i][j]=-2;
else if (j%2==1) ans[i][j]=-2;
else ans[i][j]=-1;
}
}
}
return ans;
}
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... |