#include "paint.h"
#include <bits/stdc++.h>
using namespace std;
int i,j,s,t;
int c[234567],a[234567],l=12345678,r,tt,k,y,z,n,m,x;
int minimumInstructions(int n, int m, int K, vector<int> C,vector<int> A, vector<vector<int>> B){
for (i = 0; i <K; i ++)
a[i]=-1;
for (i = 0; i <m; i ++){
for (auto u:B[i]){
a[u]=i;
}
}
t= 0;
while (t<n){
x = a[C[t]];
k = 0;
for (i = t; i<n; i ++){
if (a[C[i]]!=(x+i-t)%m){
y=i;
break;
}
}
if (i==n){
y=n;
if (y-t<m)
return -1;
s+=(y-t+m-1)/m;
break;
}
if (y-t<m)
return -1;
s+=(y-t+m-1)/m;
t=y;
}
return s;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
208 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
204 KB |
Output is correct |
13 |
Correct |
1 ms |
716 KB |
Output is correct |
14 |
Correct |
1 ms |
680 KB |
Output is correct |
15 |
Correct |
1 ms |
716 KB |
Output is correct |
16 |
Correct |
1 ms |
716 KB |
Output is correct |
17 |
Correct |
1 ms |
716 KB |
Output is correct |
18 |
Correct |
1 ms |
716 KB |
Output is correct |
19 |
Correct |
1 ms |
716 KB |
Output is correct |
20 |
Correct |
1 ms |
716 KB |
Output is correct |
21 |
Correct |
1 ms |
716 KB |
Output is correct |
22 |
Correct |
14 ms |
1988 KB |
Output is correct |
23 |
Correct |
14 ms |
1952 KB |
Output is correct |
24 |
Correct |
14 ms |
2036 KB |
Output is correct |
25 |
Correct |
3 ms |
460 KB |
Output is correct |
26 |
Correct |
3 ms |
460 KB |
Output is correct |
27 |
Correct |
3 ms |
460 KB |
Output is correct |
28 |
Correct |
3 ms |
416 KB |
Output is correct |
29 |
Correct |
3 ms |
460 KB |
Output is correct |
30 |
Correct |
3 ms |
460 KB |
Output is correct |
31 |
Correct |
7 ms |
1356 KB |
Output is correct |
32 |
Correct |
7 ms |
1256 KB |
Output is correct |
33 |
Correct |
7 ms |
1380 KB |
Output is correct |
34 |
Correct |
7 ms |
1336 KB |
Output is correct |
35 |
Correct |
7 ms |
1376 KB |
Output is correct |
36 |
Correct |
7 ms |
1356 KB |
Output is correct |
37 |
Correct |
18 ms |
2452 KB |
Output is correct |
38 |
Correct |
17 ms |
2380 KB |
Output is correct |
39 |
Correct |
17 ms |
2380 KB |
Output is correct |
40 |
Correct |
10 ms |
1100 KB |
Output is correct |
41 |
Correct |
7 ms |
844 KB |
Output is correct |
42 |
Correct |
11 ms |
1228 KB |
Output is correct |
43 |
Correct |
7 ms |
844 KB |
Output is correct |
44 |
Correct |
7 ms |
828 KB |
Output is correct |
45 |
Correct |
11 ms |
1228 KB |
Output is correct |
46 |
Correct |
36 ms |
8132 KB |
Output is correct |
47 |
Correct |
22 ms |
4520 KB |
Output is correct |
48 |
Correct |
27 ms |
7160 KB |
Output is correct |
49 |
Correct |
31 ms |
6592 KB |
Output is correct |
50 |
Correct |
32 ms |
6088 KB |
Output is correct |
51 |
Correct |
25 ms |
4292 KB |
Output is correct |
52 |
Correct |
11 ms |
1228 KB |
Output is correct |
53 |
Correct |
11 ms |
1228 KB |
Output is correct |
54 |
Correct |
11 ms |
1228 KB |
Output is correct |
55 |
Correct |
11 ms |
1228 KB |
Output is correct |
56 |
Correct |
11 ms |
1228 KB |
Output is correct |
57 |
Correct |
11 ms |
1228 KB |
Output is correct |
58 |
Correct |
41 ms |
8564 KB |
Output is correct |
59 |
Correct |
40 ms |
8548 KB |
Output is correct |
60 |
Correct |
41 ms |
8516 KB |
Output is correct |
61 |
Correct |
41 ms |
8560 KB |
Output is correct |
62 |
Correct |
42 ms |
8468 KB |
Output is correct |
63 |
Correct |
41 ms |
8492 KB |
Output is correct |
64 |
Correct |
40 ms |
7784 KB |
Output is correct |
65 |
Correct |
39 ms |
7748 KB |
Output is correct |
66 |
Correct |
40 ms |
7876 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
208 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
204 KB |
Output is correct |
13 |
Correct |
1 ms |
716 KB |
Output is correct |
14 |
Correct |
1 ms |
680 KB |
Output is correct |
15 |
Correct |
1 ms |
716 KB |
Output is correct |
16 |
Correct |
1 ms |
716 KB |
Output is correct |
17 |
Correct |
1 ms |
716 KB |
Output is correct |
18 |
Correct |
1 ms |
716 KB |
Output is correct |
19 |
Correct |
1 ms |
716 KB |
Output is correct |
20 |
Correct |
1 ms |
716 KB |
Output is correct |
21 |
Correct |
1 ms |
716 KB |
Output is correct |
22 |
Incorrect |
1 ms |
208 KB |
Output isn't correct |
23 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
208 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
208 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
208 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |