제출 #1347622

#제출 시각아이디문제언어결과실행 시간메모리
1347622modwwe죄수들의 도전 (IOI22_prison)C++20
0 / 100
4 ms580 KiB
#include<bits/stdc++.h>
using namespace std;
int a[10]= {1666,555,185,61,20,6,2};
int base[10]= {4999,1665,554,184,60,19,5,1};
vector<vector<int>> devise_strategy(int N)
{
    vector<vector<int>>f;
    f.assign(21, vector<int>(N + 1));
    for(int i=0; i<=20; i++)
    {
        int y=0;
        if(i==0)f[i][0]=0;
        else  f[i][0]=((i-1)/3+1)%2,y=(i-1)/3+1;
        for(int j=1; j<=N; j++)
        {
            int x=j-1;
            int lx=j-1;
            for(int z=0; z<y; z++)lx=x,x=x%a[z]-1;
            if(lx<=0)
            {
                if(f[i][0]==0)f[i][j]=-1;
                else f[i][j]=-2;
            }
            else if(y!=0&&lx==base[y-1]-1)
            {
                if(f[i][0]==0)f[i][j]=-2;
                else f[i][j]=-1;
            }
            else
            if(i!=0&&i-(y-1)*3-1!=lx/a[y-1])
            {
                lx=lx/a[y-1];
                if(i-(y-1)*3-1<lx)
                {
                    if(f[i][0]==0)f[i][j]=-2;
                    else f[i][j]=-1;
                }
                else
                {
                    if(f[i][0]==0)f[i][j]=-1;
                    else f[i][j]=-2;
                }
            }
            else if(x<=0)
            {
                if(f[i][0]==0)f[i][j]=-1;
                else f[i][j]=-2;
            }
            else if(x==base[y]-1)
            {
                if(f[i][0]==0)f[i][j]=-2;
                else f[i][j]=-1;
            }
            else
            {
                int hh=x/a[y];
                if(i==19||i==20)
                {
                    if(hh==0)
                    {
                        if(f[i][0]==0)f[i][j]=-1;
                        else f[i][j]=-2;
                    }
                    else
                    {
                        if(f[i][0]==0)f[i][j]=-2;
                        else f[i][j]=-1;
                    }
                }
                else
                {
                   // cout<<x/a[y]+1+y*3<<endl;
                    assert(x/a[y]+1+y*3>0);
                    f[i][j]=x/a[y]+1+y*3;
                }
            }
        }
    }
    return f;
}

#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...