이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "prison.h"
#include <bits/stdc++.h>
using namespace std;
void fill(vector<vector<int>>&a, int n, int sz, int ind) {
//cout<<"fill "<<sz<<' '<<ind<<'\n';
//int x; cin>>x;
if (sz<=8) {
int x=(sz+1)>>1;
for (int i=1; i<=n; ++i) {
a[ind][i]=ind+((i-1)%sz)/2+1;
}
for (int i=ind+1; i<=ind+x; ++i) {
a[i][0]=1;
for (int j=1; j<=n; ++j) {
if (((j-1)%sz)/2<i-ind-1) a[i][j]=-2;
else if (((j-1)%sz)/2==i-ind-1) a[i][j]=ind+x+1;
else a[i][j]=-1;
}
}
for (int i=1; i<=n; ++i) if (i&1) a[ind+x+1][i]=-1; else a[ind+x+1][i]=-2;
return;
}
for (int i=1; i<=n; ++i) {
if ((i-1)%sz<(sz+4)/5) a[ind][i]=ind+1;
else if ((i-1)%sz<2*((sz+4)/5)) a[ind][i]=ind+2;
else if ((i-1)%sz<3*((sz+4)/5)) a[ind][i]=ind+3;
else if ((i-1)%sz<4*((sz+4)/5)) a[ind][i]=ind+4;
else a[ind][i]=ind+5;
}
a[ind+1][0]=1;
for (int i=1; i<=n; ++i) {
if ((i-1)%sz<(sz+4)/5) a[ind+1][i]=ind+6;
else a[ind+1][i]=-1;
}
a[ind+2][0]=1;
for (int i=1; i<=n; ++i) {
if ((i-1)%sz<(sz+4)/5) a[ind+2][i]=-2;
else if ((i-1)%sz<2*((sz+4)/5)) a[ind+2][i]=ind+6;
else a[ind+2][i]=-1;
}
a[ind+3][0]=1;
for (int i=1; i<=n; ++i) {
if ((i-1)%sz<2*((sz+4)/5)) a[ind+3][i]=-2;
else if ((i-1)%sz<3*((sz+4)/5)) a[ind+3][i]=ind+6;
else a[ind+3][i]=-1;
}
a[ind+4][0]=1;
for (int i=1; i<=n; ++i) {
if ((i-1)%sz<3*((sz+4)/5)) a[ind+4][i]=-2;
else if ((i-1)%sz<4*((sz+4)/5)) a[ind+4][i]=ind+6;
else a[ind+4][i]=-1;
}
a[ind+5][0]=1;
for (int i=1; i<=n; ++i) {
if ((i-1)%sz<4*((sz+4)/5)) a[ind+5][i]=-2;
else a[ind+5][i]=ind+6;
}
sz=(sz+4)/5;
fill(a,n,sz,ind+6);
}
vector<vector<int>> devise_strategy(int n) {
int sz=5000;
//int need=0;
//while (sz<n) {sz*=4; need+=5;}
//cout<<need<<'\n';
vector<vector<int>> a(30,vector<int>(n+1,0));
fill(a,n,sz,0);
for (int i=0; i<30; ++i) {
//auto x=a[i];
//cout<<i<<": ";
//if (x[0]==0) cout<<"A "; else cout<<"B ";
//for (auto y:x) cout<<y<<' '; cout<<'\n';
}
return a;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |