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;
#define X first
#define Y second
int i, j, pos, curr;
int ans;
int cor[100005];
bool isN;
int minimumInstructions(int N, int M, int K, vector<int> C, vector<int> A, vector<vector<int> > B) {
fill(cor, cor+K, -1);
for (i=0; i < M; ++i) for (j=0; j < A[i]; ++j) cor[B[i][j]] = i;
for (i=0; i < N; ++i) {
if (cor[C[i]] == -1) return -1;
C[i] = cor[C[i]];
}
ans = 0;
pos = C[0];
curr = 1;
for (i=1; i < N; ++i) {
isN = false;
if (pos == M-1 && C[i] == 0) isN = true;
else if (C[i] == pos+1) isN = true;
if (!isN) {
if (curr < M) return -1;
ans += (curr+M-1)/M;
curr = 0;
}
++curr;
pos = C[i];
}
if (curr < M) return -1;
ans += (curr+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... |