#include "paint.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n, m, k;
int minimumInstructions(int N, int M, int K, vector<int> C, vector<int> A, vector<vector<int>> B) {
vector<int> a, c;
vector<vector<int>> b;
n = N;
m = M;
k = K;
c = C;
a = A;
b = B;
assert((int)c.size() == n);
assert((int)a.size() == m);
assert((int)b.size() == m);
for (int i = 0; i < m; i++) {
assert((int)b[i].size() == a[i]);
}
vector<int> f(n, 0);
for (int i = 0; i < m; i++) {
for (auto& it : b[i]) {
f[it]++;
}
}
vector<int> has(k, -1);
vector<int> need(n, 0);
for (int i = 0; i < n; i++) {
for (int i = 0; i < m; i++) {
for (auto& it : b[i]) {
has[it] = i;
}
}
}
for (int i = 0; i < n; i++) {
if (f[c[i]] == 0) {
return -1;
}
need[i] = has[c[i]];
}
int want = need[0];
int cur = 1;
for (int i = 1; i < n; i++) {
want++;
want %= m;
if (need[i] != want) {
cur++;
want = need[i];
}
}
return cur;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |