제출 #1055291

#제출 시각아이디문제언어결과실행 시간메모리
1055291Malix죄수들의 도전 (IOI22_prison)C++17
0 / 100
3 ms644 KiB
#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) { int m=22;int c=12; vii ans(m+1,vi(n+1,m+10)); REP(i,0,m+1){ if(((i+1)/2)%2==1)ans[i][0]=1; else ans[i][0]=0; } REP(j,3,n-1){ if((j-3)&(1<<(c-1)))ans[0][j]=1; else ans[0][j]=2; } REP(j,1,3){ if(j&(1<<(c-1)))ans[0][j]=1; else ans[0][j]=2; } REP(j,n-1,n+1){ if(j&(1<<(c-1)))ans[0][j]=1; else ans[0][j]=2; } REP(i,1,m+1){ if(i%2==1){ REP(j,1,3){ if(j&(1<<(c-(i+1)/2))){ if((1<<(c-(i+1)/2-1))<0){ ans[i][j]=m; continue; } if(j&(1<<(c-(i+1)/2-1)))ans[i][j]=i+2; else ans[i][j]=i+3; } else { if(((i+1)/2)%2==1)ans[i][j]=-2; else ans[i][j]=-1; } } } else{ REP(j,1,3){ if(!(j&(1<<(c-(i+1)/2)))){ if((1<<(c-(i+1)/2-1))<0){ ans[i][j]=m; continue; } if(j&(1<<(c-(i+1)/2-1)))ans[i][j]=i+1; else ans[i][j]=i+2; } else { if(((i+1)/2)%2==1)ans[i][j]=-1; else ans[i][j]=-2; } } } } REP(i,1,m+1){ if(i%2==1){ REP(j,n-1,n+1){ if(j&(1<<(c-(i+1)/2))){ if((1<<(c-(i+1)/2-1))<0){ ans[i][j]=m; continue; } if(j&(1<<(c-(i+1)/2-1)))ans[i][j]=i+2; else ans[i][j]=i+3; } else { if(((i+1)/2)%2==1)ans[i][j]=-2; else ans[i][j]=-1; } } } else{ REP(j,n-1,n+1){ if(!(j&(1<<(c-(i+1)/2)))){ if((1<<(c-(i+1)/2-1))<0){ ans[i][j]=m; continue; } if(j&(1<<(c-(i+1)/2-1)))ans[i][j]=i+1; else ans[i][j]=i+2; } else { if(((i+1)/2)%2==1)ans[i][j]=-1; else ans[i][j]=-2; } } } } REP(i,1,m+1){ if(i%2==1){ REP(j,3,n-1){ if((j-3)&(1<<(c-(i+1)/2))){ if((1<<(c-(i+1)/2-1))<0){ ans[i][j]=m; continue; } if((j-3)&(1<<(c-(i+1)/2-1)))ans[i][j]=i+2; else ans[i][j]=i+3; } else { if(((i+1)/2)%2==1)ans[i][j]=-2; else ans[i][j]=-1; } } } else{ REP(j,3,n-1){ if(!((j-3)&(1<<(c-(i+1)/2)))){ if((1<<(c-(i+1)/2-1))<0){ ans[i][j]=m; continue; } if((j-3)&(1<<(c-(i+1)/2-1)))ans[i][j]=i+1; else ans[i][j]=i+2; } else { if(((i+1)/2)%2==1)ans[i][j]=-1; else ans[i][j]=-2; } } } } ans[0][n]=-2; ans[0][1]=-1; int l=1,r=n;int p=0; REP(i,1,m+1){ if(p==0){ ans[i][l]=-2; ans[i][r]=-1; ans[i+1][l]=-2; ans[i+1][r]=-1; l++;r--;if(l>r)break; ans[i][l]=-2; ans[i][r]=-1; ans[i+1][l]=-2; ans[i+1][r]=-1; if(l>r)break; } else{ ans[i][l]=-1; ans[i][r]=-2; ans[i+1][l]=-1; ans[i+1][r]=-2; l++;r--;if(l>r)break; ans[i][l]=-1; ans[i][r]=-2; ans[i+1][l]=-1; ans[i+1][r]=-2; if(l>r)break; } p=1-p;i++; } REP(i,0,m+1)REP(j,0,n+1){ if(ans[i][j]==m+1)ans[i][j]=-2; else if(ans[i][j]==m+2)ans[i][j]=-1; } REP(i,0,m+1)REP(j,0,n+1)if(ans[i][j]>m)ans[i][j]=m; // REP(i,0,m+1){ // REP(j,0,n+1)cout<<ans[i][j]<<" "; // cout<<"\n"; // } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...