#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define pb push_back
#define ff first
#define ss second
int minimumInstructions(int n, int m, int k, vector<int> x, vector<int> A, vector<vector<int>> B){
vector<vector<bool>> f(m, vector<bool>(k));
for (int i = 0; i < m; i++){
for (int j: B[i]){
f[i][j] = 1;
}
}
vector<bool> gd(n);
for (int i = 0; i <= n - m; i++){
for (int j = 0; j < m; j++){
bool ind = 1;
for (int k = 0; k < m; k++){
if (!f[(j + k) % m][x[i + k]]){
ind = 0;
break;
}
}
if (ind){
gd[i] = 1;
break;
}
}
}
int mx = -1, t = 0, out = 0;
for (int i = 0; i < n; i++){
if (gd[i]) t = max(t, i);
if (i == (mx + 1)){
if (t == -1) return -1;
mx = t + m - 1;
t = -1;
out++;
}
}
return out;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
1 ms |
336 KB |
Output is correct |
9 |
Correct |
1 ms |
336 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
1 ms |
504 KB |
Output is correct |
13 |
Correct |
2 ms |
2896 KB |
Output is correct |
14 |
Correct |
2 ms |
2896 KB |
Output is correct |
15 |
Correct |
3 ms |
2984 KB |
Output is correct |
16 |
Correct |
2 ms |
2896 KB |
Output is correct |
17 |
Correct |
2 ms |
2896 KB |
Output is correct |
18 |
Correct |
3 ms |
3064 KB |
Output is correct |
19 |
Correct |
2 ms |
2896 KB |
Output is correct |
20 |
Correct |
2 ms |
2896 KB |
Output is correct |
21 |
Correct |
2 ms |
2896 KB |
Output is correct |
22 |
Correct |
12 ms |
4312 KB |
Output is correct |
23 |
Correct |
10 ms |
4032 KB |
Output is correct |
24 |
Correct |
10 ms |
4176 KB |
Output is correct |
25 |
Correct |
2 ms |
592 KB |
Output is correct |
26 |
Correct |
2 ms |
592 KB |
Output is correct |
27 |
Correct |
2 ms |
592 KB |
Output is correct |
28 |
Correct |
2 ms |
592 KB |
Output is correct |
29 |
Correct |
2 ms |
556 KB |
Output is correct |
30 |
Correct |
2 ms |
592 KB |
Output is correct |
31 |
Correct |
212 ms |
25680 KB |
Output is correct |
32 |
Correct |
213 ms |
25656 KB |
Output is correct |
33 |
Correct |
221 ms |
25680 KB |
Output is correct |
34 |
Correct |
210 ms |
25688 KB |
Output is correct |
35 |
Correct |
218 ms |
25680 KB |
Output is correct |
36 |
Correct |
238 ms |
25680 KB |
Output is correct |
37 |
Correct |
214 ms |
26856 KB |
Output is correct |
38 |
Correct |
186 ms |
26704 KB |
Output is correct |
39 |
Correct |
187 ms |
26704 KB |
Output is correct |
40 |
Correct |
6 ms |
1104 KB |
Output is correct |
41 |
Correct |
4 ms |
772 KB |
Output is correct |
42 |
Correct |
8 ms |
1276 KB |
Output is correct |
43 |
Correct |
5 ms |
848 KB |
Output is correct |
44 |
Correct |
5 ms |
848 KB |
Output is correct |
45 |
Correct |
8 ms |
1360 KB |
Output is correct |
46 |
Runtime error |
353 ms |
524288 KB |
Execution killed with signal 9 |
47 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
1 ms |
336 KB |
Output is correct |
9 |
Correct |
1 ms |
336 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
1 ms |
504 KB |
Output is correct |
13 |
Correct |
2 ms |
2896 KB |
Output is correct |
14 |
Correct |
2 ms |
2896 KB |
Output is correct |
15 |
Correct |
3 ms |
2984 KB |
Output is correct |
16 |
Correct |
2 ms |
2896 KB |
Output is correct |
17 |
Correct |
2 ms |
2896 KB |
Output is correct |
18 |
Correct |
3 ms |
3064 KB |
Output is correct |
19 |
Correct |
2 ms |
2896 KB |
Output is correct |
20 |
Correct |
2 ms |
2896 KB |
Output is correct |
21 |
Correct |
2 ms |
2896 KB |
Output is correct |
22 |
Correct |
1 ms |
336 KB |
Output is correct |
23 |
Correct |
1 ms |
336 KB |
Output is correct |
24 |
Correct |
1 ms |
336 KB |
Output is correct |
25 |
Incorrect |
1 ms |
552 KB |
Output isn't correct |
26 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
1 ms |
336 KB |
Output is correct |
9 |
Correct |
1 ms |
336 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
1 ms |
336 KB |
Output is correct |
13 |
Correct |
1 ms |
336 KB |
Output is correct |
14 |
Correct |
1 ms |
504 KB |
Output is correct |
15 |
Correct |
2 ms |
2896 KB |
Output is correct |
16 |
Correct |
2 ms |
2896 KB |
Output is correct |
17 |
Correct |
3 ms |
2984 KB |
Output is correct |
18 |
Correct |
2 ms |
2896 KB |
Output is correct |
19 |
Correct |
2 ms |
2896 KB |
Output is correct |
20 |
Correct |
3 ms |
3064 KB |
Output is correct |
21 |
Correct |
2 ms |
2896 KB |
Output is correct |
22 |
Correct |
2 ms |
2896 KB |
Output is correct |
23 |
Correct |
2 ms |
2896 KB |
Output is correct |
24 |
Correct |
12 ms |
4312 KB |
Output is correct |
25 |
Correct |
10 ms |
4032 KB |
Output is correct |
26 |
Correct |
10 ms |
4176 KB |
Output is correct |
27 |
Correct |
1 ms |
336 KB |
Output is correct |
28 |
Incorrect |
1 ms |
552 KB |
Output isn't correct |
29 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
1 ms |
336 KB |
Output is correct |
9 |
Correct |
1 ms |
336 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
1 ms |
336 KB |
Output is correct |
13 |
Correct |
1 ms |
336 KB |
Output is correct |
14 |
Correct |
1 ms |
504 KB |
Output is correct |
15 |
Correct |
2 ms |
2896 KB |
Output is correct |
16 |
Correct |
2 ms |
2896 KB |
Output is correct |
17 |
Correct |
3 ms |
2984 KB |
Output is correct |
18 |
Correct |
2 ms |
2896 KB |
Output is correct |
19 |
Correct |
2 ms |
2896 KB |
Output is correct |
20 |
Correct |
3 ms |
3064 KB |
Output is correct |
21 |
Correct |
2 ms |
2896 KB |
Output is correct |
22 |
Correct |
2 ms |
2896 KB |
Output is correct |
23 |
Correct |
2 ms |
2896 KB |
Output is correct |
24 |
Correct |
12 ms |
4312 KB |
Output is correct |
25 |
Correct |
10 ms |
4032 KB |
Output is correct |
26 |
Correct |
10 ms |
4176 KB |
Output is correct |
27 |
Correct |
2 ms |
592 KB |
Output is correct |
28 |
Correct |
2 ms |
592 KB |
Output is correct |
29 |
Correct |
2 ms |
592 KB |
Output is correct |
30 |
Correct |
2 ms |
592 KB |
Output is correct |
31 |
Correct |
2 ms |
556 KB |
Output is correct |
32 |
Correct |
2 ms |
592 KB |
Output is correct |
33 |
Correct |
212 ms |
25680 KB |
Output is correct |
34 |
Correct |
213 ms |
25656 KB |
Output is correct |
35 |
Correct |
221 ms |
25680 KB |
Output is correct |
36 |
Correct |
210 ms |
25688 KB |
Output is correct |
37 |
Correct |
218 ms |
25680 KB |
Output is correct |
38 |
Correct |
238 ms |
25680 KB |
Output is correct |
39 |
Correct |
214 ms |
26856 KB |
Output is correct |
40 |
Correct |
186 ms |
26704 KB |
Output is correct |
41 |
Correct |
187 ms |
26704 KB |
Output is correct |
42 |
Correct |
1 ms |
336 KB |
Output is correct |
43 |
Incorrect |
1 ms |
552 KB |
Output isn't correct |
44 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
1 ms |
336 KB |
Output is correct |
9 |
Correct |
1 ms |
336 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
1 ms |
336 KB |
Output is correct |
13 |
Correct |
1 ms |
336 KB |
Output is correct |
14 |
Correct |
1 ms |
504 KB |
Output is correct |
15 |
Correct |
2 ms |
2896 KB |
Output is correct |
16 |
Correct |
2 ms |
2896 KB |
Output is correct |
17 |
Correct |
3 ms |
2984 KB |
Output is correct |
18 |
Correct |
2 ms |
2896 KB |
Output is correct |
19 |
Correct |
2 ms |
2896 KB |
Output is correct |
20 |
Correct |
3 ms |
3064 KB |
Output is correct |
21 |
Correct |
2 ms |
2896 KB |
Output is correct |
22 |
Correct |
2 ms |
2896 KB |
Output is correct |
23 |
Correct |
2 ms |
2896 KB |
Output is correct |
24 |
Correct |
12 ms |
4312 KB |
Output is correct |
25 |
Correct |
10 ms |
4032 KB |
Output is correct |
26 |
Correct |
10 ms |
4176 KB |
Output is correct |
27 |
Correct |
2 ms |
592 KB |
Output is correct |
28 |
Correct |
2 ms |
592 KB |
Output is correct |
29 |
Correct |
2 ms |
592 KB |
Output is correct |
30 |
Correct |
2 ms |
592 KB |
Output is correct |
31 |
Correct |
2 ms |
556 KB |
Output is correct |
32 |
Correct |
2 ms |
592 KB |
Output is correct |
33 |
Correct |
212 ms |
25680 KB |
Output is correct |
34 |
Correct |
213 ms |
25656 KB |
Output is correct |
35 |
Correct |
221 ms |
25680 KB |
Output is correct |
36 |
Correct |
210 ms |
25688 KB |
Output is correct |
37 |
Correct |
218 ms |
25680 KB |
Output is correct |
38 |
Correct |
238 ms |
25680 KB |
Output is correct |
39 |
Correct |
214 ms |
26856 KB |
Output is correct |
40 |
Correct |
186 ms |
26704 KB |
Output is correct |
41 |
Correct |
187 ms |
26704 KB |
Output is correct |
42 |
Correct |
6 ms |
1104 KB |
Output is correct |
43 |
Correct |
4 ms |
772 KB |
Output is correct |
44 |
Correct |
8 ms |
1276 KB |
Output is correct |
45 |
Correct |
5 ms |
848 KB |
Output is correct |
46 |
Correct |
5 ms |
848 KB |
Output is correct |
47 |
Correct |
8 ms |
1360 KB |
Output is correct |
48 |
Runtime error |
353 ms |
524288 KB |
Execution killed with signal 9 |
49 |
Halted |
0 ms |
0 KB |
- |