이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "paint.h"
#include <vector>
#include <stdio.h>
using namespace std;
bool can[2005][100005]={0};
bool have[200005]={0};
int DP[200005];
vector < int > all;
vector < int > how[200005];
int N,M;
int F(int here)
{
int ok=0,ok2,i,j;
if(have[here]) return DP[here];
if(here==N) return 0;
have[here]=1;
if(here+M>N)
{
DP[here]=1e9;
return 1e9;
}
for(auto i:how[all[here]])
{
ok2=1;
for(j=0;j<M;j++)
{
if(can[(i+j)%M][all[here+j]]==0)
{
ok2=0;
break;
}
}
if(ok2) ok=1;
}
DP[here]=1e9;
if(ok)
{
for(i=1;i<=M;i++)
{
DP[here]=min(DP[here],F(here+i)+1);
//printf("%d %d %d\n",here,i,F(here+i)+1);
}
}
return DP[here];
}
int minimumInstructions(int N, int M, int K, vector<int> C, vector<int> A,vector< vector<int> > B)
{
int i,j;
all=C;
::N=N;
::M=M;
for(i=0;i<M;i++)
{
for(j=0;j<A[i];j++)
{
can[i][B[i][j]]=1;
how[B[i][j]].push_back(i);
}
}
int t=F(0);
if(t>=1000000000) return -1;
return t;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |