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 "paint.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int minimumInstructions(int N, int M, int K, std::vector<int> C,std::vector<int> A, std::vector<std::vector<int>> B) {
vector<int> ok;
for(int i=0;i<=N-M;i++){
for(int j=0;j<M;j++){
bool work=1;
for(int k=0;k<M;k++){
int f = lower_bound(B[(j+k)%M].begin(),B[(j+k)%M].end(),C[i+k])-B[(j+k)%M].begin();
work&=(f<A[(j+k)%M] && B[(j+k)%M][f]==C[i+k]);
}
if(work){
ok.push_back(i);
break;
}
}
}
if(ok.empty() || ok[0]!=0) return -1;
int cur = 0;
int ans = 1;
while(cur<N-M-1){
int k = upper_bound(ok.begin(),ok.end(),cur+M)-ok.begin();
k--;
if(k<0 || ok[k]==cur) return -1;
cur = ok[k];
ans++;
}
return ans;
}
# | 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... |