This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/*input
8 3 5
3 3 1 3 4 4 2 2
3 0 1 2
2 2 3
2 3 4
*/
#include "paint.h"
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define ALL(x) x.begin(),x.end()
#define pii pair<int,int>
#define f first
#define s second
#define MXTO(a,b) a=max(a,b)
#define MNTO(a,b) a=min(a,b)
#define sz(x) (int)x.size()
#define pb push_back
const int maxn=1e5+5;
int n,m;
int dp[maxn];
const int INF=0x3f3f3f3f;
int minimumInstructions(
int N, int M, int K, std::vector<int> C,
std::vector<int> A, std::vector<std::vector<int>> B) {
n=N,m=M;
REP1(i,n){
int mn=INF;
for(int j=i-1;j>=max(0,i-m);j--) MNTO(mn,dp[j]);
dp[i]=INF;
REP(k,m){
int c=k;
bool ok=1;
for(int j=max(0,i-m)+1;j<=i;j++){
bool hv=0;
for(int a:B[c]) if(a==C[j-1]){
hv=1;
break;
}
if(!hv){
ok=0;
break;
}
c=(c+1)%m;
}
if(ok){
dp[i]=mn+1;
break;
}
}
}
if(dp[n]==INF) dp[n]=-1;
return dp[n];
}
# | 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... |