Submission #961973

# Submission time Handle Problem Language Result Execution time Memory
961973 2024-04-13T00:08:45 Z Mohamed_Kachef06 Painting Walls (APIO20_paint) C++17
28 / 100
1500 ms 7760 KB
#include "paint.h"
//#include "grader.cpp"
#include <vector>
#include <bits/stdc++.h>
using namespace std;

bool poss[400'001];
int dp[100'001]; 
int n , m ,  k ;

int brute(int i){
   if (i >= n) return 0; 
   if (~dp[i]) return dp[i]; 
   int ans = 1e9; 
   if (poss[i]){
     for (int j = i+1 ; j <= i+m ; j++) ans = min(ans , brute(j) + 1);  
   }
   return dp[i] = ans; 
}

int minimumInstructions(
    int N, int M, int K, std::vector<int> C,
    std::vector<int> A, std::vector<std::vector<int>> B) {
      n = N; m = M; k = K; 
      // N number of segments 
      // M number of contractors
      // C(n) the intended color for each segment
      // A(m) the number of colors each contractor likes 
      // B(m) the set of colors each contractor likes 
      for (auto &i : B ) sort(i.begin() , i.end());
     for (int y = 0; y <= N-M ; y++){
         for (int x = 0 ; x < M ; x++){
          bool f = 1;
          for (int l = 0 ; l < M ; l++){
            int cont = (x+l)%M ; 
            if (!binary_search(B[cont].begin() , B[cont].end() , C[y+l])) {f = 0; break;} 
          }
          if (f) {poss[y] = 1; break; } 
        }
      }
      memset(dp , -1 , sizeof dp); 
      int ans = brute(0);
  return (ans == 1e9 ? -1 : ans); 
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 604 KB Output is correct
2 Correct 0 ms 604 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 0 ms 604 KB Output is correct
7 Correct 1 ms 860 KB Output is correct
8 Correct 1 ms 860 KB Output is correct
9 Correct 1 ms 604 KB Output is correct
10 Correct 1 ms 604 KB Output is correct
11 Correct 1 ms 604 KB Output is correct
12 Correct 1 ms 604 KB Output is correct
13 Correct 1 ms 860 KB Output is correct
14 Correct 1 ms 1012 KB Output is correct
15 Correct 1 ms 712 KB Output is correct
16 Correct 1 ms 860 KB Output is correct
17 Correct 1 ms 860 KB Output is correct
18 Correct 1 ms 860 KB Output is correct
19 Correct 2 ms 860 KB Output is correct
20 Correct 1 ms 860 KB Output is correct
21 Correct 1 ms 860 KB Output is correct
22 Correct 10 ms 2140 KB Output is correct
23 Correct 10 ms 1992 KB Output is correct
24 Correct 11 ms 2140 KB Output is correct
25 Correct 3 ms 1884 KB Output is correct
26 Correct 2 ms 1884 KB Output is correct
27 Correct 3 ms 860 KB Output is correct
28 Correct 3 ms 856 KB Output is correct
29 Correct 2 ms 856 KB Output is correct
30 Correct 3 ms 816 KB Output is correct
31 Correct 740 ms 2148 KB Output is correct
32 Correct 721 ms 2132 KB Output is correct
33 Correct 725 ms 2364 KB Output is correct
34 Correct 713 ms 2136 KB Output is correct
35 Correct 745 ms 2356 KB Output is correct
36 Correct 741 ms 2152 KB Output is correct
37 Correct 920 ms 2480 KB Output is correct
38 Correct 935 ms 2476 KB Output is correct
39 Correct 909 ms 2644 KB Output is correct
40 Correct 9 ms 5980 KB Output is correct
41 Correct 6 ms 3932 KB Output is correct
42 Correct 9 ms 1808 KB Output is correct
43 Correct 6 ms 1368 KB Output is correct
44 Correct 6 ms 1372 KB Output is correct
45 Correct 11 ms 1884 KB Output is correct
46 Execution timed out 1579 ms 7760 KB Time limit exceeded
47 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 604 KB Output is correct
2 Correct 0 ms 604 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 0 ms 604 KB Output is correct
7 Correct 1 ms 860 KB Output is correct
8 Correct 1 ms 860 KB Output is correct
9 Correct 1 ms 604 KB Output is correct
10 Correct 1 ms 604 KB Output is correct
11 Correct 1 ms 604 KB Output is correct
12 Correct 1 ms 604 KB Output is correct
13 Correct 1 ms 860 KB Output is correct
14 Correct 1 ms 1012 KB Output is correct
15 Correct 1 ms 712 KB Output is correct
16 Correct 1 ms 860 KB Output is correct
17 Correct 1 ms 860 KB Output is correct
18 Correct 1 ms 860 KB Output is correct
19 Correct 2 ms 860 KB Output is correct
20 Correct 1 ms 860 KB Output is correct
21 Correct 1 ms 860 KB Output is correct
22 Correct 0 ms 604 KB Output is correct
23 Correct 0 ms 604 KB Output is correct
24 Correct 0 ms 604 KB Output is correct
25 Correct 1 ms 604 KB Output is correct
26 Correct 1 ms 604 KB Output is correct
27 Correct 1 ms 604 KB Output is correct
28 Correct 1 ms 600 KB Output is correct
29 Correct 1 ms 604 KB Output is correct
30 Correct 1 ms 604 KB Output is correct
31 Correct 1 ms 860 KB Output is correct
32 Correct 1 ms 604 KB Output is correct
33 Correct 1 ms 860 KB Output is correct
34 Correct 2 ms 860 KB Output is correct
35 Correct 1 ms 860 KB Output is correct
36 Correct 1 ms 860 KB Output is correct
37 Correct 1 ms 860 KB Output is correct
38 Correct 1 ms 604 KB Output is correct
39 Correct 1 ms 604 KB Output is correct
40 Correct 1 ms 860 KB Output is correct
41 Correct 1 ms 860 KB Output is correct
42 Correct 1 ms 604 KB Output is correct
43 Correct 1 ms 604 KB Output is correct
44 Correct 1 ms 860 KB Output is correct
45 Correct 1 ms 860 KB Output is correct
46 Correct 1 ms 604 KB Output is correct
47 Correct 1 ms 604 KB Output is correct
48 Correct 1 ms 604 KB Output is correct
49 Correct 1 ms 604 KB Output is correct
50 Correct 1 ms 860 KB Output is correct
51 Correct 1 ms 1112 KB Output is correct
52 Correct 1 ms 860 KB Output is correct
53 Correct 1 ms 856 KB Output is correct
54 Correct 1 ms 860 KB Output is correct
55 Correct 1 ms 860 KB Output is correct
56 Correct 1 ms 860 KB Output is correct
57 Correct 1 ms 860 KB Output is correct
58 Correct 1 ms 860 KB Output is correct
59 Correct 1 ms 860 KB Output is correct
60 Correct 1 ms 860 KB Output is correct
61 Correct 1 ms 860 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 604 KB Output is correct
2 Correct 0 ms 604 KB Output is correct
3 Correct 0 ms 604 KB Output is correct
4 Correct 0 ms 604 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 0 ms 604 KB Output is correct
9 Correct 1 ms 860 KB Output is correct
10 Correct 1 ms 860 KB Output is correct
11 Correct 1 ms 604 KB Output is correct
12 Correct 1 ms 604 KB Output is correct
13 Correct 1 ms 604 KB Output is correct
14 Correct 1 ms 604 KB Output is correct
15 Correct 1 ms 860 KB Output is correct
16 Correct 1 ms 1012 KB Output is correct
17 Correct 1 ms 712 KB Output is correct
18 Correct 1 ms 860 KB Output is correct
19 Correct 1 ms 860 KB Output is correct
20 Correct 1 ms 860 KB Output is correct
21 Correct 2 ms 860 KB Output is correct
22 Correct 1 ms 860 KB Output is correct
23 Correct 1 ms 860 KB Output is correct
24 Correct 10 ms 2140 KB Output is correct
25 Correct 10 ms 1992 KB Output is correct
26 Correct 11 ms 2140 KB Output is correct
27 Correct 0 ms 604 KB Output is correct
28 Correct 1 ms 604 KB Output is correct
29 Correct 1 ms 604 KB Output is correct
30 Correct 1 ms 604 KB Output is correct
31 Correct 1 ms 600 KB Output is correct
32 Correct 1 ms 604 KB Output is correct
33 Correct 1 ms 604 KB Output is correct
34 Correct 1 ms 860 KB Output is correct
35 Correct 1 ms 604 KB Output is correct
36 Correct 1 ms 860 KB Output is correct
37 Correct 2 ms 860 KB Output is correct
38 Correct 1 ms 860 KB Output is correct
39 Correct 1 ms 860 KB Output is correct
40 Correct 1 ms 860 KB Output is correct
41 Correct 1 ms 604 KB Output is correct
42 Correct 1 ms 604 KB Output is correct
43 Correct 1 ms 860 KB Output is correct
44 Correct 1 ms 860 KB Output is correct
45 Correct 1 ms 604 KB Output is correct
46 Correct 1 ms 604 KB Output is correct
47 Correct 1 ms 860 KB Output is correct
48 Correct 1 ms 860 KB Output is correct
49 Correct 1 ms 604 KB Output is correct
50 Correct 1 ms 604 KB Output is correct
51 Correct 1 ms 604 KB Output is correct
52 Correct 1 ms 604 KB Output is correct
53 Correct 1 ms 860 KB Output is correct
54 Correct 1 ms 1112 KB Output is correct
55 Correct 1 ms 860 KB Output is correct
56 Correct 1 ms 856 KB Output is correct
57 Correct 1 ms 860 KB Output is correct
58 Correct 1 ms 860 KB Output is correct
59 Correct 1 ms 860 KB Output is correct
60 Correct 1 ms 860 KB Output is correct
61 Correct 1 ms 860 KB Output is correct
62 Correct 1 ms 860 KB Output is correct
63 Correct 1 ms 860 KB Output is correct
64 Correct 1 ms 860 KB Output is correct
65 Correct 1 ms 1112 KB Output is correct
66 Correct 1 ms 860 KB Output is correct
67 Correct 1 ms 860 KB Output is correct
68 Correct 1 ms 860 KB Output is correct
69 Correct 1 ms 860 KB Output is correct
70 Correct 7 ms 860 KB Output is correct
71 Correct 4 ms 968 KB Output is correct
72 Correct 4 ms 860 KB Output is correct
73 Correct 1 ms 752 KB Output is correct
74 Correct 2 ms 860 KB Output is correct
75 Correct 3 ms 856 KB Output is correct
76 Correct 10 ms 2136 KB Output is correct
77 Correct 11 ms 2760 KB Output is correct
78 Correct 12 ms 2824 KB Output is correct
79 Correct 1 ms 860 KB Output is correct
80 Correct 1 ms 700 KB Output is correct
81 Correct 1 ms 860 KB Output is correct
82 Correct 1 ms 860 KB Output is correct
83 Correct 1 ms 860 KB Output is correct
84 Correct 4 ms 860 KB Output is correct
85 Correct 8 ms 860 KB Output is correct
86 Correct 5 ms 916 KB Output is correct
87 Correct 4 ms 860 KB Output is correct
88 Correct 5 ms 1060 KB Output is correct
89 Correct 5 ms 916 KB Output is correct
90 Correct 15 ms 2908 KB Output is correct
91 Correct 20 ms 2880 KB Output is correct
92 Correct 15 ms 2900 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 604 KB Output is correct
2 Correct 0 ms 604 KB Output is correct
3 Correct 0 ms 604 KB Output is correct
4 Correct 0 ms 604 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 0 ms 604 KB Output is correct
9 Correct 1 ms 860 KB Output is correct
10 Correct 1 ms 860 KB Output is correct
11 Correct 1 ms 604 KB Output is correct
12 Correct 1 ms 604 KB Output is correct
13 Correct 1 ms 604 KB Output is correct
14 Correct 1 ms 604 KB Output is correct
15 Correct 1 ms 860 KB Output is correct
16 Correct 1 ms 1012 KB Output is correct
17 Correct 1 ms 712 KB Output is correct
18 Correct 1 ms 860 KB Output is correct
19 Correct 1 ms 860 KB Output is correct
20 Correct 1 ms 860 KB Output is correct
21 Correct 2 ms 860 KB Output is correct
22 Correct 1 ms 860 KB Output is correct
23 Correct 1 ms 860 KB Output is correct
24 Correct 10 ms 2140 KB Output is correct
25 Correct 10 ms 1992 KB Output is correct
26 Correct 11 ms 2140 KB Output is correct
27 Correct 3 ms 1884 KB Output is correct
28 Correct 2 ms 1884 KB Output is correct
29 Correct 3 ms 860 KB Output is correct
30 Correct 3 ms 856 KB Output is correct
31 Correct 2 ms 856 KB Output is correct
32 Correct 3 ms 816 KB Output is correct
33 Correct 740 ms 2148 KB Output is correct
34 Correct 721 ms 2132 KB Output is correct
35 Correct 725 ms 2364 KB Output is correct
36 Correct 713 ms 2136 KB Output is correct
37 Correct 745 ms 2356 KB Output is correct
38 Correct 741 ms 2152 KB Output is correct
39 Correct 920 ms 2480 KB Output is correct
40 Correct 935 ms 2476 KB Output is correct
41 Correct 909 ms 2644 KB Output is correct
42 Correct 0 ms 604 KB Output is correct
43 Correct 1 ms 604 KB Output is correct
44 Correct 1 ms 604 KB Output is correct
45 Correct 1 ms 604 KB Output is correct
46 Correct 1 ms 600 KB Output is correct
47 Correct 1 ms 604 KB Output is correct
48 Correct 1 ms 604 KB Output is correct
49 Correct 1 ms 860 KB Output is correct
50 Correct 1 ms 604 KB Output is correct
51 Correct 1 ms 860 KB Output is correct
52 Correct 2 ms 860 KB Output is correct
53 Correct 1 ms 860 KB Output is correct
54 Correct 1 ms 860 KB Output is correct
55 Correct 1 ms 860 KB Output is correct
56 Correct 1 ms 604 KB Output is correct
57 Correct 1 ms 604 KB Output is correct
58 Correct 1 ms 860 KB Output is correct
59 Correct 1 ms 860 KB Output is correct
60 Correct 1 ms 604 KB Output is correct
61 Correct 1 ms 604 KB Output is correct
62 Correct 1 ms 860 KB Output is correct
63 Correct 1 ms 860 KB Output is correct
64 Correct 1 ms 604 KB Output is correct
65 Correct 1 ms 604 KB Output is correct
66 Correct 1 ms 604 KB Output is correct
67 Correct 1 ms 604 KB Output is correct
68 Correct 1 ms 860 KB Output is correct
69 Correct 1 ms 1112 KB Output is correct
70 Correct 1 ms 860 KB Output is correct
71 Correct 1 ms 856 KB Output is correct
72 Correct 1 ms 860 KB Output is correct
73 Correct 1 ms 860 KB Output is correct
74 Correct 1 ms 860 KB Output is correct
75 Correct 1 ms 860 KB Output is correct
76 Correct 1 ms 860 KB Output is correct
77 Correct 1 ms 860 KB Output is correct
78 Correct 1 ms 860 KB Output is correct
79 Correct 1 ms 860 KB Output is correct
80 Correct 1 ms 1112 KB Output is correct
81 Correct 1 ms 860 KB Output is correct
82 Correct 1 ms 860 KB Output is correct
83 Correct 1 ms 860 KB Output is correct
84 Correct 1 ms 860 KB Output is correct
85 Correct 7 ms 860 KB Output is correct
86 Correct 4 ms 968 KB Output is correct
87 Correct 4 ms 860 KB Output is correct
88 Correct 1 ms 752 KB Output is correct
89 Correct 2 ms 860 KB Output is correct
90 Correct 3 ms 856 KB Output is correct
91 Correct 10 ms 2136 KB Output is correct
92 Correct 11 ms 2760 KB Output is correct
93 Correct 12 ms 2824 KB Output is correct
94 Correct 1 ms 860 KB Output is correct
95 Correct 1 ms 700 KB Output is correct
96 Correct 1 ms 860 KB Output is correct
97 Correct 1 ms 860 KB Output is correct
98 Correct 1 ms 860 KB Output is correct
99 Correct 4 ms 860 KB Output is correct
100 Correct 8 ms 860 KB Output is correct
101 Correct 5 ms 916 KB Output is correct
102 Correct 4 ms 860 KB Output is correct
103 Correct 5 ms 1060 KB Output is correct
104 Correct 5 ms 916 KB Output is correct
105 Correct 15 ms 2908 KB Output is correct
106 Correct 20 ms 2880 KB Output is correct
107 Correct 15 ms 2900 KB Output is correct
108 Correct 2 ms 2072 KB Output is correct
109 Correct 47 ms 1440 KB Output is correct
110 Correct 179 ms 852 KB Output is correct
111 Correct 151 ms 872 KB Output is correct
112 Correct 196 ms 912 KB Output is correct
113 Correct 138 ms 904 KB Output is correct
114 Correct 718 ms 2192 KB Output is correct
115 Correct 51 ms 2164 KB Output is correct
116 Correct 626 ms 2764 KB Output is correct
117 Correct 534 ms 2388 KB Output is correct
118 Correct 74 ms 2384 KB Output is correct
119 Correct 1002 ms 2104 KB Output is correct
120 Correct 491 ms 2220 KB Output is correct
121 Correct 310 ms 1636 KB Output is correct
122 Correct 231 ms 2460 KB Output is correct
123 Correct 129 ms 1544 KB Output is correct
124 Correct 157 ms 2640 KB Output is correct
125 Correct 90 ms 1956 KB Output is correct
126 Correct 24 ms 1212 KB Output is correct
127 Correct 341 ms 1368 KB Output is correct
128 Correct 81 ms 1160 KB Output is correct
129 Correct 117 ms 1184 KB Output is correct
130 Correct 3 ms 1880 KB Output is correct
131 Correct 73 ms 1872 KB Output is correct
132 Correct 292 ms 976 KB Output is correct
133 Correct 292 ms 988 KB Output is correct
134 Correct 288 ms 992 KB Output is correct
135 Correct 299 ms 1012 KB Output is correct
136 Execution timed out 1571 ms 2216 KB Time limit exceeded
137 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 604 KB Output is correct
2 Correct 0 ms 604 KB Output is correct
3 Correct 0 ms 604 KB Output is correct
4 Correct 0 ms 604 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 0 ms 604 KB Output is correct
9 Correct 1 ms 860 KB Output is correct
10 Correct 1 ms 860 KB Output is correct
11 Correct 1 ms 604 KB Output is correct
12 Correct 1 ms 604 KB Output is correct
13 Correct 1 ms 604 KB Output is correct
14 Correct 1 ms 604 KB Output is correct
15 Correct 1 ms 860 KB Output is correct
16 Correct 1 ms 1012 KB Output is correct
17 Correct 1 ms 712 KB Output is correct
18 Correct 1 ms 860 KB Output is correct
19 Correct 1 ms 860 KB Output is correct
20 Correct 1 ms 860 KB Output is correct
21 Correct 2 ms 860 KB Output is correct
22 Correct 1 ms 860 KB Output is correct
23 Correct 1 ms 860 KB Output is correct
24 Correct 10 ms 2140 KB Output is correct
25 Correct 10 ms 1992 KB Output is correct
26 Correct 11 ms 2140 KB Output is correct
27 Correct 3 ms 1884 KB Output is correct
28 Correct 2 ms 1884 KB Output is correct
29 Correct 3 ms 860 KB Output is correct
30 Correct 3 ms 856 KB Output is correct
31 Correct 2 ms 856 KB Output is correct
32 Correct 3 ms 816 KB Output is correct
33 Correct 740 ms 2148 KB Output is correct
34 Correct 721 ms 2132 KB Output is correct
35 Correct 725 ms 2364 KB Output is correct
36 Correct 713 ms 2136 KB Output is correct
37 Correct 745 ms 2356 KB Output is correct
38 Correct 741 ms 2152 KB Output is correct
39 Correct 920 ms 2480 KB Output is correct
40 Correct 935 ms 2476 KB Output is correct
41 Correct 909 ms 2644 KB Output is correct
42 Correct 9 ms 5980 KB Output is correct
43 Correct 6 ms 3932 KB Output is correct
44 Correct 9 ms 1808 KB Output is correct
45 Correct 6 ms 1368 KB Output is correct
46 Correct 6 ms 1372 KB Output is correct
47 Correct 11 ms 1884 KB Output is correct
48 Execution timed out 1579 ms 7760 KB Time limit exceeded
49 Halted 0 ms 0 KB -