Submission #962593

# Submission time Handle Problem Language Result Execution time Memory
962593 2024-04-13T23:44:58 Z Mohamed_Kachef06 Painting Walls (APIO20_paint) C++17
28 / 100
1500 ms 7912 KB
#include "paint.h"
//#include "grader.cpp"
#include <vector>
#include <bits/stdc++.h>
#define int long long 
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; 
}
 
signed minimumInstructions(
    signed N, signed M, signed K, vector<signed> C,
    vector<signed> A, vector<vector<signed>> 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 1 ms 1116 KB Output is correct
2 Correct 1 ms 1116 KB Output is correct
3 Correct 1 ms 1116 KB Output is correct
4 Correct 1 ms 1116 KB Output is correct
5 Correct 1 ms 1116 KB Output is correct
6 Correct 1 ms 1116 KB Output is correct
7 Correct 1 ms 1212 KB Output is correct
8 Correct 1 ms 1128 KB Output is correct
9 Correct 1 ms 1120 KB Output is correct
10 Correct 1 ms 1128 KB Output is correct
11 Correct 1 ms 1128 KB Output is correct
12 Correct 1 ms 1128 KB Output is correct
13 Correct 1 ms 1128 KB Output is correct
14 Correct 1 ms 1128 KB Output is correct
15 Correct 2 ms 1128 KB Output is correct
16 Correct 1 ms 1220 KB Output is correct
17 Correct 2 ms 1128 KB Output is correct
18 Correct 1 ms 1124 KB Output is correct
19 Correct 2 ms 1232 KB Output is correct
20 Correct 2 ms 1248 KB Output is correct
21 Correct 2 ms 1128 KB Output is correct
22 Correct 11 ms 2400 KB Output is correct
23 Correct 11 ms 2408 KB Output is correct
24 Correct 11 ms 2596 KB Output is correct
25 Correct 2 ms 2152 KB Output is correct
26 Correct 3 ms 2152 KB Output is correct
27 Correct 2 ms 1372 KB Output is correct
28 Correct 4 ms 1384 KB Output is correct
29 Correct 3 ms 1384 KB Output is correct
30 Correct 3 ms 1372 KB Output is correct
31 Correct 724 ms 2668 KB Output is correct
32 Correct 688 ms 2908 KB Output is correct
33 Correct 706 ms 2904 KB Output is correct
34 Correct 693 ms 2908 KB Output is correct
35 Correct 696 ms 2904 KB Output is correct
36 Correct 718 ms 2744 KB Output is correct
37 Correct 967 ms 2992 KB Output is correct
38 Correct 949 ms 2988 KB Output is correct
39 Correct 951 ms 2980 KB Output is correct
40 Correct 9 ms 6236 KB Output is correct
41 Correct 6 ms 4444 KB Output is correct
42 Correct 9 ms 2228 KB Output is correct
43 Correct 6 ms 1884 KB Output is correct
44 Correct 6 ms 1884 KB Output is correct
45 Correct 10 ms 2140 KB Output is correct
46 Execution timed out 1586 ms 7912 KB Time limit exceeded
47 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1116 KB Output is correct
2 Correct 1 ms 1116 KB Output is correct
3 Correct 1 ms 1116 KB Output is correct
4 Correct 1 ms 1116 KB Output is correct
5 Correct 1 ms 1116 KB Output is correct
6 Correct 1 ms 1116 KB Output is correct
7 Correct 1 ms 1212 KB Output is correct
8 Correct 1 ms 1128 KB Output is correct
9 Correct 1 ms 1120 KB Output is correct
10 Correct 1 ms 1128 KB Output is correct
11 Correct 1 ms 1128 KB Output is correct
12 Correct 1 ms 1128 KB Output is correct
13 Correct 1 ms 1128 KB Output is correct
14 Correct 1 ms 1128 KB Output is correct
15 Correct 2 ms 1128 KB Output is correct
16 Correct 1 ms 1220 KB Output is correct
17 Correct 2 ms 1128 KB Output is correct
18 Correct 1 ms 1124 KB Output is correct
19 Correct 2 ms 1232 KB Output is correct
20 Correct 2 ms 1248 KB Output is correct
21 Correct 2 ms 1128 KB Output is correct
22 Correct 1 ms 1112 KB Output is correct
23 Correct 1 ms 1116 KB Output is correct
24 Correct 1 ms 1116 KB Output is correct
25 Correct 1 ms 1116 KB Output is correct
26 Correct 1 ms 1116 KB Output is correct
27 Correct 1 ms 1116 KB Output is correct
28 Correct 1 ms 1116 KB Output is correct
29 Correct 1 ms 1116 KB Output is correct
30 Correct 1 ms 1116 KB Output is correct
31 Correct 1 ms 1116 KB Output is correct
32 Correct 1 ms 1116 KB Output is correct
33 Correct 1 ms 1116 KB Output is correct
34 Correct 1 ms 1112 KB Output is correct
35 Correct 1 ms 1116 KB Output is correct
36 Correct 1 ms 1116 KB Output is correct
37 Correct 1 ms 1116 KB Output is correct
38 Correct 1 ms 1116 KB Output is correct
39 Correct 1 ms 1116 KB Output is correct
40 Correct 1 ms 1116 KB Output is correct
41 Correct 1 ms 1116 KB Output is correct
42 Correct 1 ms 1232 KB Output is correct
43 Correct 1 ms 1116 KB Output is correct
44 Correct 1 ms 1116 KB Output is correct
45 Correct 1 ms 1268 KB Output is correct
46 Correct 1 ms 1112 KB Output is correct
47 Correct 1 ms 1112 KB Output is correct
48 Correct 1 ms 1116 KB Output is correct
49 Correct 1 ms 1116 KB Output is correct
50 Correct 1 ms 1116 KB Output is correct
51 Correct 1 ms 1116 KB Output is correct
52 Correct 1 ms 1112 KB Output is correct
53 Correct 1 ms 1368 KB Output is correct
54 Correct 1 ms 1112 KB Output is correct
55 Correct 1 ms 1116 KB Output is correct
56 Correct 1 ms 1116 KB Output is correct
57 Correct 1 ms 1116 KB Output is correct
58 Correct 1 ms 1116 KB Output is correct
59 Correct 1 ms 1116 KB Output is correct
60 Correct 2 ms 1116 KB Output is correct
61 Correct 1 ms 1116 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1112 KB Output is correct
2 Correct 1 ms 1116 KB Output is correct
3 Correct 1 ms 1116 KB Output is correct
4 Correct 1 ms 1116 KB Output is correct
5 Correct 1 ms 1116 KB Output is correct
6 Correct 1 ms 1116 KB Output is correct
7 Correct 1 ms 1116 KB Output is correct
8 Correct 1 ms 1116 KB Output is correct
9 Correct 1 ms 1212 KB Output is correct
10 Correct 1 ms 1128 KB Output is correct
11 Correct 1 ms 1120 KB Output is correct
12 Correct 1 ms 1128 KB Output is correct
13 Correct 1 ms 1128 KB Output is correct
14 Correct 1 ms 1128 KB Output is correct
15 Correct 1 ms 1128 KB Output is correct
16 Correct 1 ms 1128 KB Output is correct
17 Correct 2 ms 1128 KB Output is correct
18 Correct 1 ms 1220 KB Output is correct
19 Correct 2 ms 1128 KB Output is correct
20 Correct 1 ms 1124 KB Output is correct
21 Correct 2 ms 1232 KB Output is correct
22 Correct 2 ms 1248 KB Output is correct
23 Correct 2 ms 1128 KB Output is correct
24 Correct 11 ms 2400 KB Output is correct
25 Correct 11 ms 2408 KB Output is correct
26 Correct 11 ms 2596 KB Output is correct
27 Correct 1 ms 1116 KB Output is correct
28 Correct 1 ms 1116 KB Output is correct
29 Correct 1 ms 1116 KB Output is correct
30 Correct 1 ms 1116 KB Output is correct
31 Correct 1 ms 1116 KB Output is correct
32 Correct 1 ms 1116 KB Output is correct
33 Correct 1 ms 1116 KB Output is correct
34 Correct 1 ms 1116 KB Output is correct
35 Correct 1 ms 1116 KB Output is correct
36 Correct 1 ms 1116 KB Output is correct
37 Correct 1 ms 1112 KB Output is correct
38 Correct 1 ms 1116 KB Output is correct
39 Correct 1 ms 1116 KB Output is correct
40 Correct 1 ms 1116 KB Output is correct
41 Correct 1 ms 1116 KB Output is correct
42 Correct 1 ms 1116 KB Output is correct
43 Correct 1 ms 1116 KB Output is correct
44 Correct 1 ms 1116 KB Output is correct
45 Correct 1 ms 1232 KB Output is correct
46 Correct 1 ms 1116 KB Output is correct
47 Correct 1 ms 1116 KB Output is correct
48 Correct 1 ms 1268 KB Output is correct
49 Correct 1 ms 1112 KB Output is correct
50 Correct 1 ms 1112 KB Output is correct
51 Correct 1 ms 1116 KB Output is correct
52 Correct 1 ms 1116 KB Output is correct
53 Correct 1 ms 1116 KB Output is correct
54 Correct 1 ms 1116 KB Output is correct
55 Correct 1 ms 1112 KB Output is correct
56 Correct 1 ms 1368 KB Output is correct
57 Correct 1 ms 1112 KB Output is correct
58 Correct 1 ms 1116 KB Output is correct
59 Correct 1 ms 1116 KB Output is correct
60 Correct 1 ms 1116 KB Output is correct
61 Correct 1 ms 1116 KB Output is correct
62 Correct 1 ms 1116 KB Output is correct
63 Correct 2 ms 1116 KB Output is correct
64 Correct 1 ms 1116 KB Output is correct
65 Correct 1 ms 1116 KB Output is correct
66 Correct 1 ms 1120 KB Output is correct
67 Correct 1 ms 1128 KB Output is correct
68 Correct 1 ms 1124 KB Output is correct
69 Correct 1 ms 1220 KB Output is correct
70 Correct 7 ms 1224 KB Output is correct
71 Correct 4 ms 1304 KB Output is correct
72 Correct 3 ms 1384 KB Output is correct
73 Correct 1 ms 1120 KB Output is correct
74 Correct 3 ms 1376 KB Output is correct
75 Correct 3 ms 1120 KB Output is correct
76 Correct 11 ms 2664 KB Output is correct
77 Correct 11 ms 2684 KB Output is correct
78 Correct 12 ms 3176 KB Output is correct
79 Correct 1 ms 1128 KB Output is correct
80 Correct 1 ms 1220 KB Output is correct
81 Correct 1 ms 1128 KB Output is correct
82 Correct 1 ms 1228 KB Output is correct
83 Correct 1 ms 1128 KB Output is correct
84 Correct 4 ms 1328 KB Output is correct
85 Correct 10 ms 1320 KB Output is correct
86 Correct 6 ms 1384 KB Output is correct
87 Correct 5 ms 1436 KB Output is correct
88 Correct 5 ms 1384 KB Output is correct
89 Correct 5 ms 1384 KB Output is correct
90 Correct 24 ms 3368 KB Output is correct
91 Correct 15 ms 3176 KB Output is correct
92 Correct 16 ms 3176 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1112 KB Output is correct
2 Correct 1 ms 1116 KB Output is correct
3 Correct 1 ms 1116 KB Output is correct
4 Correct 1 ms 1116 KB Output is correct
5 Correct 1 ms 1116 KB Output is correct
6 Correct 1 ms 1116 KB Output is correct
7 Correct 1 ms 1116 KB Output is correct
8 Correct 1 ms 1116 KB Output is correct
9 Correct 1 ms 1212 KB Output is correct
10 Correct 1 ms 1128 KB Output is correct
11 Correct 1 ms 1120 KB Output is correct
12 Correct 1 ms 1128 KB Output is correct
13 Correct 1 ms 1128 KB Output is correct
14 Correct 1 ms 1128 KB Output is correct
15 Correct 1 ms 1128 KB Output is correct
16 Correct 1 ms 1128 KB Output is correct
17 Correct 2 ms 1128 KB Output is correct
18 Correct 1 ms 1220 KB Output is correct
19 Correct 2 ms 1128 KB Output is correct
20 Correct 1 ms 1124 KB Output is correct
21 Correct 2 ms 1232 KB Output is correct
22 Correct 2 ms 1248 KB Output is correct
23 Correct 2 ms 1128 KB Output is correct
24 Correct 11 ms 2400 KB Output is correct
25 Correct 11 ms 2408 KB Output is correct
26 Correct 11 ms 2596 KB Output is correct
27 Correct 2 ms 2152 KB Output is correct
28 Correct 3 ms 2152 KB Output is correct
29 Correct 2 ms 1372 KB Output is correct
30 Correct 4 ms 1384 KB Output is correct
31 Correct 3 ms 1384 KB Output is correct
32 Correct 3 ms 1372 KB Output is correct
33 Correct 724 ms 2668 KB Output is correct
34 Correct 688 ms 2908 KB Output is correct
35 Correct 706 ms 2904 KB Output is correct
36 Correct 693 ms 2908 KB Output is correct
37 Correct 696 ms 2904 KB Output is correct
38 Correct 718 ms 2744 KB Output is correct
39 Correct 967 ms 2992 KB Output is correct
40 Correct 949 ms 2988 KB Output is correct
41 Correct 951 ms 2980 KB Output is correct
42 Correct 1 ms 1116 KB Output is correct
43 Correct 1 ms 1116 KB Output is correct
44 Correct 1 ms 1116 KB Output is correct
45 Correct 1 ms 1116 KB Output is correct
46 Correct 1 ms 1116 KB Output is correct
47 Correct 1 ms 1116 KB Output is correct
48 Correct 1 ms 1116 KB Output is correct
49 Correct 1 ms 1116 KB Output is correct
50 Correct 1 ms 1116 KB Output is correct
51 Correct 1 ms 1116 KB Output is correct
52 Correct 1 ms 1112 KB Output is correct
53 Correct 1 ms 1116 KB Output is correct
54 Correct 1 ms 1116 KB Output is correct
55 Correct 1 ms 1116 KB Output is correct
56 Correct 1 ms 1116 KB Output is correct
57 Correct 1 ms 1116 KB Output is correct
58 Correct 1 ms 1116 KB Output is correct
59 Correct 1 ms 1116 KB Output is correct
60 Correct 1 ms 1232 KB Output is correct
61 Correct 1 ms 1116 KB Output is correct
62 Correct 1 ms 1116 KB Output is correct
63 Correct 1 ms 1268 KB Output is correct
64 Correct 1 ms 1112 KB Output is correct
65 Correct 1 ms 1112 KB Output is correct
66 Correct 1 ms 1116 KB Output is correct
67 Correct 1 ms 1116 KB Output is correct
68 Correct 1 ms 1116 KB Output is correct
69 Correct 1 ms 1116 KB Output is correct
70 Correct 1 ms 1112 KB Output is correct
71 Correct 1 ms 1368 KB Output is correct
72 Correct 1 ms 1112 KB Output is correct
73 Correct 1 ms 1116 KB Output is correct
74 Correct 1 ms 1116 KB Output is correct
75 Correct 1 ms 1116 KB Output is correct
76 Correct 1 ms 1116 KB Output is correct
77 Correct 1 ms 1116 KB Output is correct
78 Correct 2 ms 1116 KB Output is correct
79 Correct 1 ms 1116 KB Output is correct
80 Correct 1 ms 1116 KB Output is correct
81 Correct 1 ms 1120 KB Output is correct
82 Correct 1 ms 1128 KB Output is correct
83 Correct 1 ms 1124 KB Output is correct
84 Correct 1 ms 1220 KB Output is correct
85 Correct 7 ms 1224 KB Output is correct
86 Correct 4 ms 1304 KB Output is correct
87 Correct 3 ms 1384 KB Output is correct
88 Correct 1 ms 1120 KB Output is correct
89 Correct 3 ms 1376 KB Output is correct
90 Correct 3 ms 1120 KB Output is correct
91 Correct 11 ms 2664 KB Output is correct
92 Correct 11 ms 2684 KB Output is correct
93 Correct 12 ms 3176 KB Output is correct
94 Correct 1 ms 1128 KB Output is correct
95 Correct 1 ms 1220 KB Output is correct
96 Correct 1 ms 1128 KB Output is correct
97 Correct 1 ms 1228 KB Output is correct
98 Correct 1 ms 1128 KB Output is correct
99 Correct 4 ms 1328 KB Output is correct
100 Correct 10 ms 1320 KB Output is correct
101 Correct 6 ms 1384 KB Output is correct
102 Correct 5 ms 1436 KB Output is correct
103 Correct 5 ms 1384 KB Output is correct
104 Correct 5 ms 1384 KB Output is correct
105 Correct 24 ms 3368 KB Output is correct
106 Correct 15 ms 3176 KB Output is correct
107 Correct 16 ms 3176 KB Output is correct
108 Correct 3 ms 2152 KB Output is correct
109 Correct 48 ms 1888 KB Output is correct
110 Correct 173 ms 1396 KB Output is correct
111 Correct 143 ms 1364 KB Output is correct
112 Correct 191 ms 1184 KB Output is correct
113 Correct 135 ms 1408 KB Output is correct
114 Correct 716 ms 2448 KB Output is correct
115 Correct 52 ms 2904 KB Output is correct
116 Correct 650 ms 3260 KB Output is correct
117 Correct 563 ms 2628 KB Output is correct
118 Correct 73 ms 2644 KB Output is correct
119 Correct 1008 ms 2616 KB Output is correct
120 Correct 502 ms 2728 KB Output is correct
121 Correct 289 ms 1872 KB Output is correct
122 Correct 239 ms 2972 KB Output is correct
123 Correct 126 ms 1876 KB Output is correct
124 Correct 167 ms 3152 KB Output is correct
125 Correct 95 ms 2384 KB Output is correct
126 Correct 25 ms 1740 KB Output is correct
127 Correct 343 ms 1884 KB Output is correct
128 Correct 89 ms 1876 KB Output is correct
129 Correct 120 ms 1700 KB Output is correct
130 Correct 3 ms 2356 KB Output is correct
131 Correct 69 ms 2244 KB Output is correct
132 Correct 284 ms 1476 KB Output is correct
133 Correct 285 ms 1492 KB Output is correct
134 Correct 291 ms 1260 KB Output is correct
135 Correct 286 ms 1512 KB Output is correct
136 Execution timed out 1560 ms 1968 KB Time limit exceeded
137 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1112 KB Output is correct
2 Correct 1 ms 1116 KB Output is correct
3 Correct 1 ms 1116 KB Output is correct
4 Correct 1 ms 1116 KB Output is correct
5 Correct 1 ms 1116 KB Output is correct
6 Correct 1 ms 1116 KB Output is correct
7 Correct 1 ms 1116 KB Output is correct
8 Correct 1 ms 1116 KB Output is correct
9 Correct 1 ms 1212 KB Output is correct
10 Correct 1 ms 1128 KB Output is correct
11 Correct 1 ms 1120 KB Output is correct
12 Correct 1 ms 1128 KB Output is correct
13 Correct 1 ms 1128 KB Output is correct
14 Correct 1 ms 1128 KB Output is correct
15 Correct 1 ms 1128 KB Output is correct
16 Correct 1 ms 1128 KB Output is correct
17 Correct 2 ms 1128 KB Output is correct
18 Correct 1 ms 1220 KB Output is correct
19 Correct 2 ms 1128 KB Output is correct
20 Correct 1 ms 1124 KB Output is correct
21 Correct 2 ms 1232 KB Output is correct
22 Correct 2 ms 1248 KB Output is correct
23 Correct 2 ms 1128 KB Output is correct
24 Correct 11 ms 2400 KB Output is correct
25 Correct 11 ms 2408 KB Output is correct
26 Correct 11 ms 2596 KB Output is correct
27 Correct 2 ms 2152 KB Output is correct
28 Correct 3 ms 2152 KB Output is correct
29 Correct 2 ms 1372 KB Output is correct
30 Correct 4 ms 1384 KB Output is correct
31 Correct 3 ms 1384 KB Output is correct
32 Correct 3 ms 1372 KB Output is correct
33 Correct 724 ms 2668 KB Output is correct
34 Correct 688 ms 2908 KB Output is correct
35 Correct 706 ms 2904 KB Output is correct
36 Correct 693 ms 2908 KB Output is correct
37 Correct 696 ms 2904 KB Output is correct
38 Correct 718 ms 2744 KB Output is correct
39 Correct 967 ms 2992 KB Output is correct
40 Correct 949 ms 2988 KB Output is correct
41 Correct 951 ms 2980 KB Output is correct
42 Correct 9 ms 6236 KB Output is correct
43 Correct 6 ms 4444 KB Output is correct
44 Correct 9 ms 2228 KB Output is correct
45 Correct 6 ms 1884 KB Output is correct
46 Correct 6 ms 1884 KB Output is correct
47 Correct 10 ms 2140 KB Output is correct
48 Execution timed out 1586 ms 7912 KB Time limit exceeded
49 Halted 0 ms 0 KB -