# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
627148 | haojiandan | Prisoner Challenge (IOI22_prison) | C++17 | 13 ms | 1096 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;
int Get(int x) {
if (x==0) return -1; return -2;
}
int Q(int x,int i) {
for (int j=0;j<i;j++) x/=3; return x%3;
}
vector<vector<int>> devise_strategy(int n) {
vector<vector<int> > res(25,vector<int>(n+1));
res[0][0]=0;
for (int i=1;i<=n;i++) res[0][i]=Q(i,7)+1;
for (int i=1;i<=24;i++) {
int bit=7-(i+2)/3+1;
res[i][0]=(i%6==0||i%6==5||i%6==4?0:1);
int lst=(i%3-1+3)%3;
int nxt; if (i%3==0) nxt=i+1; else if (i%3==2) nxt=i+2; else nxt=i+3;
for (int j=1;j<=n;j++) {
int now=Q(j,bit);
if (now!=lst) {
if (now<lst) res[i][j]=Get(res[i][0]);
else res[i][j]=Get(res[i][0]^1);
} else {
res[i][j]=nxt+Q(j,bit-1);
res[i][j]=min(res[i][j],24);
}
}
}
/*for (int i=0;i<=26;i++) {
for (int j=1;j<=n;j++) printf("%d ",res[i][j]); puts("");
}*/
return res;
}
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... |