이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "prison.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef pair<int,int> pi;
typedef vector<pi> pii;
typedef tuple<int,int,int> tii;
typedef vector<ll> li;
typedef vector<li> lii;
#define REP(i,a,b) for(int i=a;i<b;i++)
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define LSOne(s) ((s)&(-s))
ll INF=1e18+10;
int inf=1e9+10;
ll M=1e9+7;
std::vector<std::vector<int>> devise_strategy(int n) {
vii tern(5001,vi(10,0));
int c=1;
for(int i=8;i>=0;i--){
int pos=0;
while(pos<=n){
REP(j,pos,min(n+1,pos+c))tern[j][i]=0;
pos+=c;
REP(j,pos,min(n+1,pos+c))tern[j][i]=1;
pos+=c;
REP(j,pos,min(n+1,pos+c))tern[j][i]=2;
pos+=c;
}
c*=3;
}
int m=22;
vii ans(m+1,vi(n+1));
REP(i,0,m+1){
if(((i+2)/3)%2==1)ans[i][0]=1;
else ans[i][0]=0;
}
REP(j,1,n+1){
if(tern[j][1]==0)ans[0][j]=1;
else if(tern[j][1]==1) ans[0][j]=2;
else if(tern[j][1]==2) ans[0][j]=3;
}
REP(i,1,m){
if(i%3==1){
REP(j,1,n+1){
if(tern[j][(i+2)/3]==2||tern[j][(i+2)/3]==1){
if(((i+2)/3)%2==1)ans[i][j]=-1;
else ans[i][j]=-2;
}
else{
if(tern[j][(i+2)/3+1]==0)ans[i][j]=i+3;
else if(tern[j][(i+2)/3+1]==1)ans[i][j]=i+4;
else ans[i][j]=i+5;
}
}
}
else if(i%3==2){
REP(j,1,n+1){
if(tern[j][(i+2)/3]==2){
if(((i+2)/3)%2==1)ans[i][j]=-1;
else ans[i][j]=-2;
}
else if(tern[j][(i+2)/3]==0){
if(((i+2)/3)%2==1)ans[i][j]=-2;
else ans[i][j]=-1;
}
else{
if(tern[j][(i+2)/3+1]==0)ans[i][j]=i+2;
else if(tern[j][(i+2)/3+1]==1)ans[i][j]=i+3;
else ans[i][j]=i+4;
}
}
}
else{
REP(j,1,n+1){
if(tern[j][(i+2)/3]==0||tern[j][(i+2)/3]==1){
if(((i+2)/3)%2==1)ans[i][j]=-2;
else ans[i][j]=-1;
}
else{
if(tern[j][(i+2)/3+1]==0)ans[i][j]=i+1;
else if(tern[j][(i+2)/3+1]==1)ans[i][j]=i+2;
else ans[i][j]=i+3;
}
}
}
}
REP(i,1,m){
REP(j,1,n+1){
if(ans[i][j]==m)ans[i][j]=-2;
else if(ans[i][j]==m+2)ans[i][j]=-1;
else if(ans[i][j]==m+1)ans[i][j]=22;
}
}
REP(j,1,n+1){
if(tern[j][8]==0)ans[22][j]=-1;
else ans[22][j]=-2;
}
// REP(i,0,m+1){
// REP(j,0,n+1)cerr<<ans[i][j]<<" ";
// cerr<<"\n";
// }
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |