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 <vector>
#include <bits/stdc++.h>
using namespace std;
const int mxn = 1e5+10;
#define pii pair<int,int>
#define fs first
#define sc second
int col[mxn];
int minimumInstructions(
int N, int M, int K, std::vector<int> C,
std::vector<int> A, std::vector<std::vector<int>> B) {
for(int i = 0;i<M;i++){
for(int j = 0;j<A[i];j++)col[B[i][j]] = i;
}
vector<pii> v;
for(int i = 0;i<N;i++)C[i] = col[C[i]];
for(int i = 0;i<N;i++){
if(v.empty()||(C[v.back().sc]+1)%M != C[i])v.push_back(pii(i,i));
else v.back().sc = i;
}
int ans = 0;
for(auto &i:v){
if(i.sc-i.fs+1<M)return -1;
ans += (i.sc-i.fs+1+M-1)/M;
}
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... |