#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 |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
308 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
724 KB |
Output is correct |
14 |
Correct |
1 ms |
724 KB |
Output is correct |
15 |
Correct |
1 ms |
692 KB |
Output is correct |
16 |
Correct |
1 ms |
608 KB |
Output is correct |
17 |
Correct |
1 ms |
724 KB |
Output is correct |
18 |
Correct |
1 ms |
724 KB |
Output is correct |
19 |
Correct |
1 ms |
724 KB |
Output is correct |
20 |
Correct |
1 ms |
724 KB |
Output is correct |
21 |
Correct |
1 ms |
724 KB |
Output is correct |
22 |
Correct |
8 ms |
2004 KB |
Output is correct |
23 |
Correct |
8 ms |
1980 KB |
Output is correct |
24 |
Correct |
10 ms |
2004 KB |
Output is correct |
25 |
Correct |
2 ms |
468 KB |
Output is correct |
26 |
Correct |
2 ms |
468 KB |
Output is correct |
27 |
Correct |
2 ms |
468 KB |
Output is correct |
28 |
Correct |
2 ms |
468 KB |
Output is correct |
29 |
Correct |
2 ms |
468 KB |
Output is correct |
30 |
Correct |
2 ms |
468 KB |
Output is correct |
31 |
Correct |
4 ms |
1364 KB |
Output is correct |
32 |
Correct |
4 ms |
1364 KB |
Output is correct |
33 |
Correct |
4 ms |
1364 KB |
Output is correct |
34 |
Correct |
4 ms |
1296 KB |
Output is correct |
35 |
Correct |
5 ms |
1364 KB |
Output is correct |
36 |
Correct |
4 ms |
1260 KB |
Output is correct |
37 |
Correct |
9 ms |
2388 KB |
Output is correct |
38 |
Correct |
9 ms |
2468 KB |
Output is correct |
39 |
Correct |
9 ms |
2396 KB |
Output is correct |
40 |
Correct |
6 ms |
1108 KB |
Output is correct |
41 |
Correct |
4 ms |
852 KB |
Output is correct |
42 |
Correct |
7 ms |
1220 KB |
Output is correct |
43 |
Correct |
5 ms |
852 KB |
Output is correct |
44 |
Correct |
5 ms |
852 KB |
Output is correct |
45 |
Correct |
7 ms |
1272 KB |
Output is correct |
46 |
Correct |
23 ms |
8032 KB |
Output is correct |
47 |
Correct |
13 ms |
4616 KB |
Output is correct |
48 |
Correct |
17 ms |
7052 KB |
Output is correct |
49 |
Correct |
19 ms |
6512 KB |
Output is correct |
50 |
Correct |
19 ms |
6164 KB |
Output is correct |
51 |
Correct |
15 ms |
4308 KB |
Output is correct |
52 |
Correct |
7 ms |
1236 KB |
Output is correct |
53 |
Correct |
7 ms |
1236 KB |
Output is correct |
54 |
Correct |
7 ms |
1236 KB |
Output is correct |
55 |
Correct |
7 ms |
1284 KB |
Output is correct |
56 |
Correct |
7 ms |
1292 KB |
Output is correct |
57 |
Correct |
7 ms |
1236 KB |
Output is correct |
58 |
Correct |
24 ms |
8480 KB |
Output is correct |
59 |
Correct |
25 ms |
8576 KB |
Output is correct |
60 |
Correct |
24 ms |
8500 KB |
Output is correct |
61 |
Correct |
24 ms |
8524 KB |
Output is correct |
62 |
Correct |
24 ms |
8560 KB |
Output is correct |
63 |
Correct |
25 ms |
8532 KB |
Output is correct |
64 |
Correct |
24 ms |
7732 KB |
Output is correct |
65 |
Correct |
24 ms |
7740 KB |
Output is correct |
66 |
Correct |
25 ms |
7720 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
308 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
724 KB |
Output is correct |
14 |
Correct |
1 ms |
724 KB |
Output is correct |
15 |
Correct |
1 ms |
692 KB |
Output is correct |
16 |
Correct |
1 ms |
608 KB |
Output is correct |
17 |
Correct |
1 ms |
724 KB |
Output is correct |
18 |
Correct |
1 ms |
724 KB |
Output is correct |
19 |
Correct |
1 ms |
724 KB |
Output is correct |
20 |
Correct |
1 ms |
724 KB |
Output is correct |
21 |
Correct |
1 ms |
724 KB |
Output is correct |
22 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
23 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |