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<bits/stdc++.h>
using namespace std;
//#include "prison.h"
typedef int ll;
vector<vector<ll>> s;
ll cad[]={ 3, 3, 3, 3, 3, 2, 2, 2, 2};
ll P[20][5588]={ };
void sol(ll p,ll a, ll b)
{
if(a>=b) return;
P[p][a]=-1e9;
P[p][b]=1e9;
if(a+1==b) return;
ll t1=(b-a-1)/cad[p];
ll t2=(b-a-1)%cad[p];
ll c=0;
for(int i=a+1; i<b;c++)
{
for(int j=0;j<t1+t2; j++)
{
P[p][i+j]=c;
}
sol(p+1,i,i+t1+t2-1);
i=i+t1+t2;
t2--;t2=max(t2,0);
}
}
ll Hash(ll p, ll vp) { return vp*9+p; }
std::vector<std::vector<int>> devise_strategy(int n) {
sol(0,1,5588);
s.assign(29,vector<ll>(n+1,0));
s[0][0]=0;s[0][1]=-1;s[0][n]=-2;
for(int i=2; i<n; i++)
s[0][i]=Hash(1,P[0][i]);
for(int i=1; i<29; i++)
{
ll temp=i;
ll va=temp%9;
temp/=9;
swap(va,temp);
s[i][0]=max((temp%2),0);
temp--;
for(int j=1; j<=n; j++)
{
ll vp=P[temp][j];
if(va==vp)s[i][j]=Hash(temp+2,P[temp+1][j]);
else if((s[i][0]==0&&vp<va)||(s[i][0]==1&&vp>va)) s[i][j]=-1;
else s[i][j]=-2;
if(s[i][j]>=29) s[i][j]=-2+s[i][0];
if(s[i][j]<-1e7) s[i][j]=-1-s[i][0];
}
}
/*for(int i=2; i<29; i++)
{
cout<<s[i][0]<<" ";
for(int j=1; j<=3; j++)
{
cout<<s[i][j]<<P[i/2-1][j]<<" ";
}
cout<<"\n";
}*/
return s;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |