#include "paint.h"
#include <vector>
#include <stdio.h>
using namespace std;
bool can[2005][100005]={0};
bool have[200005]={0};
int DP[200005];
vector < int > all;
int N,M;
int F(int here)
{
int ok=0,ok2,i,j;
if(have[here]) return DP[here];
if(here==N) return 0;
have[here]=1;
if(here+M>N)
{
DP[here]=1e9;
return 1e9;
}
for(i=0;i<M;i++)
{
ok2=1;
for(j=0;j<M;j++)
{
if(can[(i+j)%M][all[here+j]]==0)
{
ok2=0;
break;
}
}
if(ok2) ok=1;
}
DP[here]=1e9;
if(ok)
{
for(i=1;i<=M;i++)
{
DP[here]=min(DP[here],F(here+i)+1);
//printf("%d %d %d\n",here,i,F(here+i)+1);
}
}
return DP[here];
}
int minimumInstructions(int N, int M, int K, vector<int> C, vector<int> A,vector< vector<int> > B)
{
int i,j;
all=C;
::N=N;
::M=M;
for(i=0;i<M;i++) for(j=0;j<A[i];j++) can[i][B[i][j]]=1;
int t=F(0);
if(t>=1000000000) return -1;
return t;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
256 KB |
Output is correct |
3 |
Correct |
0 ms |
256 KB |
Output is correct |
4 |
Correct |
0 ms |
256 KB |
Output is correct |
5 |
Correct |
0 ms |
256 KB |
Output is correct |
6 |
Correct |
0 ms |
256 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
0 ms |
384 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
0 ms |
384 KB |
Output is correct |
11 |
Correct |
0 ms |
384 KB |
Output is correct |
12 |
Correct |
0 ms |
384 KB |
Output is correct |
13 |
Correct |
5 ms |
2304 KB |
Output is correct |
14 |
Correct |
5 ms |
2304 KB |
Output is correct |
15 |
Correct |
5 ms |
2304 KB |
Output is correct |
16 |
Correct |
5 ms |
2304 KB |
Output is correct |
17 |
Correct |
5 ms |
2304 KB |
Output is correct |
18 |
Correct |
5 ms |
2304 KB |
Output is correct |
19 |
Correct |
3 ms |
3968 KB |
Output is correct |
20 |
Correct |
3 ms |
3968 KB |
Output is correct |
21 |
Correct |
3 ms |
3968 KB |
Output is correct |
22 |
Correct |
30 ms |
20728 KB |
Output is correct |
23 |
Correct |
25 ms |
20728 KB |
Output is correct |
24 |
Correct |
27 ms |
20728 KB |
Output is correct |
25 |
Correct |
3 ms |
1280 KB |
Output is correct |
26 |
Correct |
3 ms |
1280 KB |
Output is correct |
27 |
Correct |
2 ms |
512 KB |
Output is correct |
28 |
Correct |
3 ms |
640 KB |
Output is correct |
29 |
Correct |
3 ms |
512 KB |
Output is correct |
30 |
Correct |
2 ms |
512 KB |
Output is correct |
31 |
Correct |
1434 ms |
69292 KB |
Output is correct |
32 |
Correct |
1468 ms |
68956 KB |
Output is correct |
33 |
Correct |
1447 ms |
68984 KB |
Output is correct |
34 |
Execution timed out |
1516 ms |
68984 KB |
Time limit exceeded |
35 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
256 KB |
Output is correct |
4 |
Correct |
0 ms |
256 KB |
Output is correct |
5 |
Correct |
0 ms |
256 KB |
Output is correct |
6 |
Correct |
0 ms |
256 KB |
Output is correct |
7 |
Correct |
0 ms |
256 KB |
Output is correct |
8 |
Correct |
0 ms |
256 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
0 ms |
384 KB |
Output is correct |
11 |
Correct |
1 ms |
384 KB |
Output is correct |
12 |
Correct |
0 ms |
384 KB |
Output is correct |
13 |
Correct |
0 ms |
384 KB |
Output is correct |
14 |
Correct |
0 ms |
384 KB |
Output is correct |
15 |
Correct |
5 ms |
2304 KB |
Output is correct |
16 |
Correct |
5 ms |
2304 KB |
Output is correct |
17 |
Correct |
5 ms |
2304 KB |
Output is correct |
18 |
Correct |
5 ms |
2304 KB |
Output is correct |
19 |
Correct |
5 ms |
2304 KB |
Output is correct |
20 |
Correct |
5 ms |
2304 KB |
Output is correct |
21 |
Correct |
3 ms |
3968 KB |
Output is correct |
22 |
Correct |
3 ms |
3968 KB |
Output is correct |
23 |
Correct |
3 ms |
3968 KB |
Output is correct |
24 |
Correct |
0 ms |
256 KB |
Output is correct |
25 |
Correct |
0 ms |
256 KB |
Output is correct |
26 |
Correct |
0 ms |
256 KB |
Output is correct |
27 |
Correct |
1 ms |
384 KB |
Output is correct |
28 |
Correct |
2 ms |
384 KB |
Output is correct |
29 |
Correct |
1 ms |
512 KB |
Output is correct |
30 |
Correct |
1 ms |
384 KB |
Output is correct |
31 |
Correct |
1 ms |
384 KB |
Output is correct |
32 |
Correct |
1 ms |
512 KB |
Output is correct |
33 |
Correct |
5 ms |
1920 KB |
Output is correct |
34 |
Correct |
4 ms |
2048 KB |
Output is correct |
35 |
Correct |
2 ms |
1408 KB |
Output is correct |
36 |
Correct |
4 ms |
1792 KB |
Output is correct |
37 |
Correct |
3 ms |
1664 KB |
Output is correct |
38 |
Correct |
1 ms |
640 KB |
Output is correct |
39 |
Correct |
0 ms |
384 KB |
Output is correct |
40 |
Correct |
3 ms |
3584 KB |
Output is correct |
41 |
Correct |
1 ms |
1024 KB |
Output is correct |
42 |
Correct |
3 ms |
2688 KB |
Output is correct |
43 |
Correct |
3 ms |
1792 KB |
Output is correct |
44 |
Correct |
0 ms |
384 KB |
Output is correct |
45 |
Correct |
3 ms |
488 KB |
Output is correct |
46 |
Correct |
1 ms |
512 KB |
Output is correct |
47 |
Correct |
1 ms |
512 KB |
Output is correct |
48 |
Correct |
0 ms |
512 KB |
Output is correct |
49 |
Correct |
1 ms |
640 KB |
Output is correct |
50 |
Correct |
5 ms |
2304 KB |
Output is correct |
51 |
Correct |
5 ms |
2304 KB |
Output is correct |
52 |
Correct |
5 ms |
2304 KB |
Output is correct |
53 |
Correct |
5 ms |
2304 KB |
Output is correct |
54 |
Correct |
5 ms |
2304 KB |
Output is correct |
55 |
Correct |
5 ms |
2304 KB |
Output is correct |
56 |
Correct |
3 ms |
3968 KB |
Output is correct |
57 |
Correct |
2 ms |
1152 KB |
Output is correct |
58 |
Correct |
3 ms |
3968 KB |
Output is correct |
59 |
Correct |
2 ms |
1280 KB |
Output is correct |
60 |
Correct |
3 ms |
3968 KB |
Output is correct |
61 |
Correct |
2 ms |
1152 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
256 KB |
Output is correct |
4 |
Correct |
0 ms |
256 KB |
Output is correct |
5 |
Correct |
0 ms |
256 KB |
Output is correct |
6 |
Correct |
0 ms |
256 KB |
Output is correct |
7 |
Correct |
0 ms |
256 KB |
Output is correct |
8 |
Correct |
0 ms |
256 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
0 ms |
384 KB |
Output is correct |
11 |
Correct |
1 ms |
384 KB |
Output is correct |
12 |
Correct |
0 ms |
384 KB |
Output is correct |
13 |
Correct |
0 ms |
384 KB |
Output is correct |
14 |
Correct |
0 ms |
384 KB |
Output is correct |
15 |
Correct |
5 ms |
2304 KB |
Output is correct |
16 |
Correct |
5 ms |
2304 KB |
Output is correct |
17 |
Correct |
5 ms |
2304 KB |
Output is correct |
18 |
Correct |
5 ms |
2304 KB |
Output is correct |
19 |
Correct |
5 ms |
2304 KB |
Output is correct |
20 |
Correct |
5 ms |
2304 KB |
Output is correct |
21 |
Correct |
3 ms |
3968 KB |
Output is correct |
22 |
Correct |
3 ms |
3968 KB |
Output is correct |
23 |
Correct |
3 ms |
3968 KB |
Output is correct |
24 |
Correct |
30 ms |
20728 KB |
Output is correct |
25 |
Correct |
25 ms |
20728 KB |
Output is correct |
26 |
Correct |
27 ms |
20728 KB |
Output is correct |
27 |
Correct |
0 ms |
256 KB |
Output is correct |
28 |
Correct |
0 ms |
256 KB |
Output is correct |
29 |
Correct |
0 ms |
256 KB |
Output is correct |
30 |
Correct |
1 ms |
384 KB |
Output is correct |
31 |
Correct |
2 ms |
384 KB |
Output is correct |
32 |
Correct |
1 ms |
512 KB |
Output is correct |
33 |
Correct |
1 ms |
384 KB |
Output is correct |
34 |
Correct |
1 ms |
384 KB |
Output is correct |
35 |
Correct |
1 ms |
512 KB |
Output is correct |
36 |
Correct |
5 ms |
1920 KB |
Output is correct |
37 |
Correct |
4 ms |
2048 KB |
Output is correct |
38 |
Correct |
2 ms |
1408 KB |
Output is correct |
39 |
Correct |
4 ms |
1792 KB |
Output is correct |
40 |
Correct |
3 ms |
1664 KB |
Output is correct |
41 |
Correct |
1 ms |
640 KB |
Output is correct |
42 |
Correct |
0 ms |
384 KB |
Output is correct |
43 |
Correct |
3 ms |
3584 KB |
Output is correct |
44 |
Correct |
1 ms |
1024 KB |
Output is correct |
45 |
Correct |
3 ms |
2688 KB |
Output is correct |
46 |
Correct |
3 ms |
1792 KB |
Output is correct |
47 |
Correct |
0 ms |
384 KB |
Output is correct |
48 |
Correct |
3 ms |
488 KB |
Output is correct |
49 |
Correct |
1 ms |
512 KB |
Output is correct |
50 |
Correct |
1 ms |
512 KB |
Output is correct |
51 |
Correct |
0 ms |
512 KB |
Output is correct |
52 |
Correct |
1 ms |
640 KB |
Output is correct |
53 |
Correct |
5 ms |
2304 KB |
Output is correct |
54 |
Correct |
5 ms |
2304 KB |
Output is correct |
55 |
Correct |
5 ms |
2304 KB |
Output is correct |
56 |
Correct |
5 ms |
2304 KB |
Output is correct |
57 |
Correct |
5 ms |
2304 KB |
Output is correct |
58 |
Correct |
5 ms |
2304 KB |
Output is correct |
59 |
Correct |
3 ms |
3968 KB |
Output is correct |
60 |
Correct |
2 ms |
1152 KB |
Output is correct |
61 |
Correct |
3 ms |
3968 KB |
Output is correct |
62 |
Correct |
2 ms |
1280 KB |
Output is correct |
63 |
Correct |
3 ms |
3968 KB |
Output is correct |
64 |
Correct |
2 ms |
1152 KB |
Output is correct |
65 |
Correct |
14 ms |
1152 KB |
Output is correct |
66 |
Correct |
5 ms |
512 KB |
Output is correct |
67 |
Correct |
35 ms |
896 KB |
Output is correct |
68 |
Correct |
12 ms |
640 KB |
Output is correct |
69 |
Correct |
26 ms |
768 KB |
Output is correct |
70 |
Correct |
18 ms |
15104 KB |
Output is correct |
71 |
Correct |
15 ms |
11136 KB |
Output is correct |
72 |
Correct |
8 ms |
5248 KB |
Output is correct |
73 |
Correct |
2 ms |
1536 KB |
Output is correct |
74 |
Correct |
12 ms |
8960 KB |
Output is correct |
75 |
Correct |
16 ms |
15616 KB |
Output is correct |
76 |
Correct |
21 ms |
9464 KB |
Output is correct |
77 |
Correct |
18 ms |
1536 KB |
Output is correct |
78 |
Correct |
24 ms |
4736 KB |
Output is correct |
79 |
Correct |
67 ms |
1232 KB |
Output is correct |
80 |
Correct |
66 ms |
1152 KB |
Output is correct |
81 |
Correct |
66 ms |
1152 KB |
Output is correct |
82 |
Correct |
67 ms |
1228 KB |
Output is correct |
83 |
Correct |
70 ms |
1152 KB |
Output is correct |
84 |
Correct |
27 ms |
18944 KB |
Output is correct |
85 |
Correct |
26 ms |
18944 KB |
Output is correct |
86 |
Correct |
27 ms |
19064 KB |
Output is correct |
87 |
Correct |
26 ms |
19200 KB |
Output is correct |
88 |
Correct |
27 ms |
19072 KB |
Output is correct |
89 |
Correct |
26 ms |
18688 KB |
Output is correct |
90 |
Correct |
34 ms |
21112 KB |
Output is correct |
91 |
Correct |
34 ms |
21112 KB |
Output is correct |
92 |
Correct |
35 ms |
21112 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
256 KB |
Output is correct |
4 |
Correct |
0 ms |
256 KB |
Output is correct |
5 |
Correct |
0 ms |
256 KB |
Output is correct |
6 |
Correct |
0 ms |
256 KB |
Output is correct |
7 |
Correct |
0 ms |
256 KB |
Output is correct |
8 |
Correct |
0 ms |
256 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
0 ms |
384 KB |
Output is correct |
11 |
Correct |
1 ms |
384 KB |
Output is correct |
12 |
Correct |
0 ms |
384 KB |
Output is correct |
13 |
Correct |
0 ms |
384 KB |
Output is correct |
14 |
Correct |
0 ms |
384 KB |
Output is correct |
15 |
Correct |
5 ms |
2304 KB |
Output is correct |
16 |
Correct |
5 ms |
2304 KB |
Output is correct |
17 |
Correct |
5 ms |
2304 KB |
Output is correct |
18 |
Correct |
5 ms |
2304 KB |
Output is correct |
19 |
Correct |
5 ms |
2304 KB |
Output is correct |
20 |
Correct |
5 ms |
2304 KB |
Output is correct |
21 |
Correct |
3 ms |
3968 KB |
Output is correct |
22 |
Correct |
3 ms |
3968 KB |
Output is correct |
23 |
Correct |
3 ms |
3968 KB |
Output is correct |
24 |
Correct |
30 ms |
20728 KB |
Output is correct |
25 |
Correct |
25 ms |
20728 KB |
Output is correct |
26 |
Correct |
27 ms |
20728 KB |
Output is correct |
27 |
Correct |
3 ms |
1280 KB |
Output is correct |
28 |
Correct |
3 ms |
1280 KB |
Output is correct |
29 |
Correct |
2 ms |
512 KB |
Output is correct |
30 |
Correct |
3 ms |
640 KB |
Output is correct |
31 |
Correct |
3 ms |
512 KB |
Output is correct |
32 |
Correct |
2 ms |
512 KB |
Output is correct |
33 |
Correct |
1434 ms |
69292 KB |
Output is correct |
34 |
Correct |
1468 ms |
68956 KB |
Output is correct |
35 |
Correct |
1447 ms |
68984 KB |
Output is correct |
36 |
Execution timed out |
1516 ms |
68984 KB |
Time limit exceeded |
37 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
256 KB |
Output is correct |
4 |
Correct |
0 ms |
256 KB |
Output is correct |
5 |
Correct |
0 ms |
256 KB |
Output is correct |
6 |
Correct |
0 ms |
256 KB |
Output is correct |
7 |
Correct |
0 ms |
256 KB |
Output is correct |
8 |
Correct |
0 ms |
256 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
0 ms |
384 KB |
Output is correct |
11 |
Correct |
1 ms |
384 KB |
Output is correct |
12 |
Correct |
0 ms |
384 KB |
Output is correct |
13 |
Correct |
0 ms |
384 KB |
Output is correct |
14 |
Correct |
0 ms |
384 KB |
Output is correct |
15 |
Correct |
5 ms |
2304 KB |
Output is correct |
16 |
Correct |
5 ms |
2304 KB |
Output is correct |
17 |
Correct |
5 ms |
2304 KB |
Output is correct |
18 |
Correct |
5 ms |
2304 KB |
Output is correct |
19 |
Correct |
5 ms |
2304 KB |
Output is correct |
20 |
Correct |
5 ms |
2304 KB |
Output is correct |
21 |
Correct |
3 ms |
3968 KB |
Output is correct |
22 |
Correct |
3 ms |
3968 KB |
Output is correct |
23 |
Correct |
3 ms |
3968 KB |
Output is correct |
24 |
Correct |
30 ms |
20728 KB |
Output is correct |
25 |
Correct |
25 ms |
20728 KB |
Output is correct |
26 |
Correct |
27 ms |
20728 KB |
Output is correct |
27 |
Correct |
3 ms |
1280 KB |
Output is correct |
28 |
Correct |
3 ms |
1280 KB |
Output is correct |
29 |
Correct |
2 ms |
512 KB |
Output is correct |
30 |
Correct |
3 ms |
640 KB |
Output is correct |
31 |
Correct |
3 ms |
512 KB |
Output is correct |
32 |
Correct |
2 ms |
512 KB |
Output is correct |
33 |
Correct |
1434 ms |
69292 KB |
Output is correct |
34 |
Correct |
1468 ms |
68956 KB |
Output is correct |
35 |
Correct |
1447 ms |
68984 KB |
Output is correct |
36 |
Execution timed out |
1516 ms |
68984 KB |
Time limit exceeded |
37 |
Halted |
0 ms |
0 KB |
- |