#include "paint.h"
#include <vector>
#include <iostream>
#include <set>
#include <map>
#include <cmath>
using namespace std;
const int maxn = 1e6 + 200, maxm = 1e3 + 200, inf = 1e9;
int n, m, k;
int cnt[maxn];
int minimumInstructions(int N, int M, int K, vector<int> C, vector<int> A, vector<vector<int>> B) {
n = N, m = M, k = K;
for (int i = 0; i < k; ++i){
cnt[i] = -1;
}
for (int i = 0; i < m; ++i){
for (auto it : B[i]){
cnt[it] = i;
}
}
for (int i = 0; i < n; i += m){
int x = cnt[C[i]];
if (x == -1){
return -1;
}
int y = 0;
while (y < m && i + y < n){
int ok = 0;
for (auto it : B[x]){
if (it == C[y + i]){
ok = 1;
break;
}
}
if (ok == 0){
return -1;
}
x = (x + 1) % m, y += 1;
}
}
return (n + m - 1) / m;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 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 |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
300 KB |
Output is correct |
12 |
Correct |
0 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 |
724 KB |
Output is correct |
17 |
Correct |
1 ms |
724 KB |
Output is correct |
18 |
Correct |
1 ms |
680 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 |
704 KB |
Output is correct |
22 |
Correct |
9 ms |
2004 KB |
Output is correct |
23 |
Correct |
9 ms |
2004 KB |
Output is correct |
24 |
Correct |
9 ms |
2004 KB |
Output is correct |
25 |
Correct |
2 ms |
448 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 |
5 ms |
1260 KB |
Output is correct |
32 |
Correct |
5 ms |
1364 KB |
Output is correct |
33 |
Correct |
5 ms |
1364 KB |
Output is correct |
34 |
Correct |
5 ms |
1264 KB |
Output is correct |
35 |
Correct |
5 ms |
1348 KB |
Output is correct |
36 |
Correct |
5 ms |
1392 KB |
Output is correct |
37 |
Correct |
13 ms |
2572 KB |
Output is correct |
38 |
Correct |
11 ms |
2428 KB |
Output is correct |
39 |
Correct |
11 ms |
2392 KB |
Output is correct |
40 |
Correct |
7 ms |
1108 KB |
Output is correct |
41 |
Correct |
4 ms |
852 KB |
Output is correct |
42 |
Correct |
9 ms |
1284 KB |
Output is correct |
43 |
Correct |
5 ms |
828 KB |
Output is correct |
44 |
Correct |
5 ms |
852 KB |
Output is correct |
45 |
Correct |
7 ms |
1236 KB |
Output is correct |
46 |
Correct |
27 ms |
8056 KB |
Output is correct |
47 |
Correct |
16 ms |
4560 KB |
Output is correct |
48 |
Correct |
20 ms |
7116 KB |
Output is correct |
49 |
Correct |
22 ms |
6544 KB |
Output is correct |
50 |
Correct |
23 ms |
6088 KB |
Output is correct |
51 |
Correct |
17 ms |
4308 KB |
Output is correct |
52 |
Correct |
7 ms |
1236 KB |
Output is correct |
53 |
Correct |
11 ms |
1296 KB |
Output is correct |
54 |
Correct |
8 ms |
1288 KB |
Output is correct |
55 |
Correct |
8 ms |
1236 KB |
Output is correct |
56 |
Correct |
8 ms |
1288 KB |
Output is correct |
57 |
Correct |
8 ms |
1216 KB |
Output is correct |
58 |
Correct |
31 ms |
8668 KB |
Output is correct |
59 |
Correct |
31 ms |
8516 KB |
Output is correct |
60 |
Correct |
29 ms |
8504 KB |
Output is correct |
61 |
Correct |
28 ms |
8532 KB |
Output is correct |
62 |
Correct |
31 ms |
8564 KB |
Output is correct |
63 |
Correct |
29 ms |
8544 KB |
Output is correct |
64 |
Correct |
27 ms |
7728 KB |
Output is correct |
65 |
Correct |
28 ms |
7720 KB |
Output is correct |
66 |
Correct |
28 ms |
7756 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 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 |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
300 KB |
Output is correct |
12 |
Correct |
0 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 |
724 KB |
Output is correct |
17 |
Correct |
1 ms |
724 KB |
Output is correct |
18 |
Correct |
1 ms |
680 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 |
704 KB |
Output is correct |
22 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
23 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |