Submission #965689

# Submission time Handle Problem Language Result Execution time Memory
965689 2024-04-19T05:25:16 Z Gromp15 Painting Walls (APIO20_paint) C++17
28 / 100
1500 ms 13148 KB
#include "paint.h"
#include <bits/stdc++.h>
#define all(x) x.begin(), x.end()
using namespace std;
template<typename T> bool ckmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> bool ckmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

const int INF = 1e9;
int minimumInstructions(
    int n, int m, int k, std::vector<int> c,
    std::vector<int> a, std::vector<std::vector<int>> b) {
	vector<int> dp(n+1, INF);
	vector<vector<int>> have(k);
	for (int i = 0; i < m; i++) {
		for (int j = 0; j < a[i]; j++) {
			have[b[i][j]].emplace_back(i);
		}
	}
	dp[0] = 0;
	for (int i = 0; i + m - 1 < n; i++) {
		for (int j : have[c[i]]) {
			bool ok = 1;
			for (int k = 1; k < m; k++) {
				if (!binary_search(all(have[c[i + k]]), (j + k) % m)) {
					ok = 0;
					break;
				}
			}
			if (ok) {
				for (int k = i+1; k <= i+m; k++) {
					ckmin(dp[k], dp[i] + 1);
				}
			}
		}
	}
	return dp[n] == INF ? -1 : dp[n];
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 600 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 2 ms 2652 KB Output is correct
14 Correct 2 ms 2652 KB Output is correct
15 Correct 1 ms 2652 KB Output is correct
16 Correct 2 ms 2652 KB Output is correct
17 Correct 2 ms 2652 KB Output is correct
18 Correct 2 ms 2648 KB Output is correct
19 Correct 1 ms 2744 KB Output is correct
20 Correct 1 ms 2648 KB Output is correct
21 Correct 2 ms 2652 KB Output is correct
22 Correct 15 ms 7180 KB Output is correct
23 Correct 16 ms 7260 KB Output is correct
24 Correct 15 ms 7256 KB Output is correct
25 Correct 2 ms 604 KB Output is correct
26 Correct 2 ms 604 KB Output is correct
27 Correct 2 ms 600 KB Output is correct
28 Correct 2 ms 604 KB Output is correct
29 Correct 2 ms 604 KB Output is correct
30 Correct 2 ms 700 KB Output is correct
31 Correct 205 ms 3932 KB Output is correct
32 Correct 201 ms 3928 KB Output is correct
33 Correct 198 ms 4128 KB Output is correct
34 Correct 210 ms 4184 KB Output is correct
35 Correct 205 ms 3932 KB Output is correct
36 Correct 203 ms 4184 KB Output is correct
37 Correct 17 ms 7772 KB Output is correct
38 Correct 17 ms 7768 KB Output is correct
39 Correct 17 ms 7772 KB Output is correct
40 Correct 6 ms 1444 KB Output is correct
41 Correct 4 ms 1116 KB Output is correct
42 Correct 8 ms 1628 KB Output is correct
43 Correct 6 ms 1116 KB Output is correct
44 Correct 5 ms 1272 KB Output is correct
45 Correct 8 ms 1672 KB Output is correct
46 Execution timed out 1544 ms 13148 KB Time limit exceeded
47 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 600 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 2 ms 2652 KB Output is correct
14 Correct 2 ms 2652 KB Output is correct
15 Correct 1 ms 2652 KB Output is correct
16 Correct 2 ms 2652 KB Output is correct
17 Correct 2 ms 2652 KB Output is correct
18 Correct 2 ms 2648 KB Output is correct
19 Correct 1 ms 2744 KB Output is correct
20 Correct 1 ms 2648 KB Output is correct
21 Correct 2 ms 2652 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 0 ms 432 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 0 ms 600 KB Output is correct
28 Correct 2 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 1 ms 344 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 1 ms 2392 KB Output is correct
34 Correct 1 ms 1884 KB Output is correct
35 Correct 1 ms 1628 KB Output is correct
36 Correct 2 ms 2748 KB Output is correct
37 Correct 1 ms 2140 KB Output is correct
38 Correct 1 ms 2396 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 1 ms 2140 KB Output is correct
41 Correct 1 ms 348 KB Output is correct
42 Correct 2 ms 2652 KB Output is correct
43 Correct 1 ms 2396 KB Output is correct
44 Correct 0 ms 348 KB Output is correct
45 Correct 4 ms 348 KB Output is correct
46 Correct 1 ms 344 KB Output is correct
47 Correct 1 ms 348 KB Output is correct
48 Correct 1 ms 348 KB Output is correct
49 Correct 1 ms 348 KB Output is correct
50 Correct 2 ms 2652 KB Output is correct
51 Correct 2 ms 2740 KB Output is correct
52 Correct 2 ms 2652 KB Output is correct
53 Correct 2 ms 2648 KB Output is correct
54 Correct 2 ms 2652 KB Output is correct
55 Correct 2 ms 2652 KB Output is correct
56 Correct 2 ms 2652 KB Output is correct
57 Correct 1 ms 348 KB Output is correct
58 Correct 2 ms 2652 KB Output is correct
59 Correct 1 ms 348 KB Output is correct
60 Correct 2 ms 2652 KB Output is correct
61 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 432 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 600 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 2 ms 2652 KB Output is correct
16 Correct 2 ms 2652 KB Output is correct
17 Correct 1 ms 2652 KB Output is correct
18 Correct 2 ms 2652 KB Output is correct
19 Correct 2 ms 2652 KB Output is correct
20 Correct 2 ms 2648 KB Output is correct
21 Correct 1 ms 2744 KB Output is correct
22 Correct 1 ms 2648 KB Output is correct
23 Correct 2 ms 2652 KB Output is correct
24 Correct 15 ms 7180 KB Output is correct
25 Correct 16 ms 7260 KB Output is correct
26 Correct 15 ms 7256 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 0 ms 600 KB Output is correct
31 Correct 2 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 1 ms 344 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 1 ms 2392 KB Output is correct
37 Correct 1 ms 1884 KB Output is correct
38 Correct 1 ms 1628 KB Output is correct
39 Correct 2 ms 2748 KB Output is correct
40 Correct 1 ms 2140 KB Output is correct
41 Correct 1 ms 2396 KB Output is correct
42 Correct 0 ms 348 KB Output is correct
43 Correct 1 ms 2140 KB Output is correct
44 Correct 1 ms 348 KB Output is correct
45 Correct 2 ms 2652 KB Output is correct
46 Correct 1 ms 2396 KB Output is correct
47 Correct 0 ms 348 KB Output is correct
48 Correct 4 ms 348 KB Output is correct
49 Correct 1 ms 344 KB Output is correct
50 Correct 1 ms 348 KB Output is correct
51 Correct 1 ms 348 KB Output is correct
52 Correct 1 ms 348 KB Output is correct
53 Correct 2 ms 2652 KB Output is correct
54 Correct 2 ms 2740 KB Output is correct
55 Correct 2 ms 2652 KB Output is correct
56 Correct 2 ms 2648 KB Output is correct
57 Correct 2 ms 2652 KB Output is correct
58 Correct 2 ms 2652 KB Output is correct
59 Correct 2 ms 2652 KB Output is correct
60 Correct 1 ms 348 KB Output is correct
61 Correct 2 ms 2652 KB Output is correct
62 Correct 1 ms 348 KB Output is correct
63 Correct 2 ms 2652 KB Output is correct
64 Correct 1 ms 348 KB Output is correct
65 Correct 27 ms 344 KB Output is correct
66 Correct 6 ms 348 KB Output is correct
67 Correct 62 ms 348 KB Output is correct
68 Correct 22 ms 344 KB Output is correct
69 Correct 50 ms 348 KB Output is correct
70 Correct 8 ms 2648 KB Output is correct
71 Correct 8 ms 2240 KB Output is correct
72 Correct 7 ms 1880 KB Output is correct
73 Correct 2 ms 2140 KB Output is correct
74 Correct 8 ms 2396 KB Output is correct
75 Correct 6 ms 2908 KB Output is correct
76 Correct 15 ms 5212 KB Output is correct
77 Correct 15 ms 6232 KB Output is correct
78 Correct 19 ms 7004 KB Output is correct
79 Correct 139 ms 348 KB Output is correct
80 Correct 142 ms 596 KB Output is correct
81 Correct 138 ms 448 KB Output is correct
82 Correct 138 ms 344 KB Output is correct
83 Correct 137 ms 600 KB Output is correct
84 Correct 13 ms 2904 KB Output is correct
85 Correct 13 ms 2908 KB Output is correct
86 Correct 13 ms 2908 KB Output is correct
87 Correct 12 ms 2908 KB Output is correct
88 Correct 12 ms 2904 KB Output is correct
89 Correct 13 ms 2908 KB Output is correct
90 Correct 21 ms 7260 KB Output is correct
91 Correct 21 ms 7284 KB Output is correct
92 Correct 21 ms 7260 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 432 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 600 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 2 ms 2652 KB Output is correct
16 Correct 2 ms 2652 KB Output is correct
17 Correct 1 ms 2652 KB Output is correct
18 Correct 2 ms 2652 KB Output is correct
19 Correct 2 ms 2652 KB Output is correct
20 Correct 2 ms 2648 KB Output is correct
21 Correct 1 ms 2744 KB Output is correct
22 Correct 1 ms 2648 KB Output is correct
23 Correct 2 ms 2652 KB Output is correct
24 Correct 15 ms 7180 KB Output is correct
25 Correct 16 ms 7260 KB Output is correct
26 Correct 15 ms 7256 KB Output is correct
27 Correct 2 ms 604 KB Output is correct
28 Correct 2 ms 604 KB Output is correct
29 Correct 2 ms 600 KB Output is correct
30 Correct 2 ms 604 KB Output is correct
31 Correct 2 ms 604 KB Output is correct
32 Correct 2 ms 700 KB Output is correct
33 Correct 205 ms 3932 KB Output is correct
34 Correct 201 ms 3928 KB Output is correct
35 Correct 198 ms 4128 KB Output is correct
36 Correct 210 ms 4184 KB Output is correct
37 Correct 205 ms 3932 KB Output is correct
38 Correct 203 ms 4184 KB Output is correct
39 Correct 17 ms 7772 KB Output is correct
40 Correct 17 ms 7768 KB Output is correct
41 Correct 17 ms 7772 KB Output is correct
42 Correct 0 ms 348 KB Output is correct
43 Correct 0 ms 348 KB Output is correct
44 Correct 1 ms 348 KB Output is correct
45 Correct 0 ms 600 KB Output is correct
46 Correct 2 ms 348 KB Output is correct
47 Correct 0 ms 348 KB Output is correct
48 Correct 1 ms 344 KB Output is correct
49 Correct 1 ms 348 KB Output is correct
50 Correct 0 ms 348 KB Output is correct
51 Correct 1 ms 2392 KB Output is correct
52 Correct 1 ms 1884 KB Output is correct
53 Correct 1 ms 1628 KB Output is correct
54 Correct 2 ms 2748 KB Output is correct
55 Correct 1 ms 2140 KB Output is correct
56 Correct 1 ms 2396 KB Output is correct
57 Correct 0 ms 348 KB Output is correct
58 Correct 1 ms 2140 KB Output is correct
59 Correct 1 ms 348 KB Output is correct
60 Correct 2 ms 2652 KB Output is correct
61 Correct 1 ms 2396 KB Output is correct
62 Correct 0 ms 348 KB Output is correct
63 Correct 4 ms 348 KB Output is correct
64 Correct 1 ms 344 KB Output is correct
65 Correct 1 ms 348 KB Output is correct
66 Correct 1 ms 348 KB Output is correct
67 Correct 1 ms 348 KB Output is correct
68 Correct 2 ms 2652 KB Output is correct
69 Correct 2 ms 2740 KB Output is correct
70 Correct 2 ms 2652 KB Output is correct
71 Correct 2 ms 2648 KB Output is correct
72 Correct 2 ms 2652 KB Output is correct
73 Correct 2 ms 2652 KB Output is correct
74 Correct 2 ms 2652 KB Output is correct
75 Correct 1 ms 348 KB Output is correct
76 Correct 2 ms 2652 KB Output is correct
77 Correct 1 ms 348 KB Output is correct
78 Correct 2 ms 2652 KB Output is correct
79 Correct 1 ms 348 KB Output is correct
80 Correct 27 ms 344 KB Output is correct
81 Correct 6 ms 348 KB Output is correct
82 Correct 62 ms 348 KB Output is correct
83 Correct 22 ms 344 KB Output is correct
84 Correct 50 ms 348 KB Output is correct
85 Correct 8 ms 2648 KB Output is correct
86 Correct 8 ms 2240 KB Output is correct
87 Correct 7 ms 1880 KB Output is correct
88 Correct 2 ms 2140 KB Output is correct
89 Correct 8 ms 2396 KB Output is correct
90 Correct 6 ms 2908 KB Output is correct
91 Correct 15 ms 5212 KB Output is correct
92 Correct 15 ms 6232 KB Output is correct
93 Correct 19 ms 7004 KB Output is correct
94 Correct 139 ms 348 KB Output is correct
95 Correct 142 ms 596 KB Output is correct
96 Correct 138 ms 448 KB Output is correct
97 Correct 138 ms 344 KB Output is correct
98 Correct 137 ms 600 KB Output is correct
99 Correct 13 ms 2904 KB Output is correct
100 Correct 13 ms 2908 KB Output is correct
101 Correct 13 ms 2908 KB Output is correct
102 Correct 12 ms 2908 KB Output is correct
103 Correct 12 ms 2904 KB Output is correct
104 Correct 13 ms 2908 KB Output is correct
105 Correct 21 ms 7260 KB Output is correct
106 Correct 21 ms 7284 KB Output is correct
107 Correct 21 ms 7260 KB Output is correct
108 Correct 2 ms 548 KB Output is correct
109 Execution timed out 1542 ms 604 KB Time limit exceeded
110 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 432 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 600 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 2 ms 2652 KB Output is correct
16 Correct 2 ms 2652 KB Output is correct
17 Correct 1 ms 2652 KB Output is correct
18 Correct 2 ms 2652 KB Output is correct
19 Correct 2 ms 2652 KB Output is correct
20 Correct 2 ms 2648 KB Output is correct
21 Correct 1 ms 2744 KB Output is correct
22 Correct 1 ms 2648 KB Output is correct
23 Correct 2 ms 2652 KB Output is correct
24 Correct 15 ms 7180 KB Output is correct
25 Correct 16 ms 7260 KB Output is correct
26 Correct 15 ms 7256 KB Output is correct
27 Correct 2 ms 604 KB Output is correct
28 Correct 2 ms 604 KB Output is correct
29 Correct 2 ms 600 KB Output is correct
30 Correct 2 ms 604 KB Output is correct
31 Correct 2 ms 604 KB Output is correct
32 Correct 2 ms 700 KB Output is correct
33 Correct 205 ms 3932 KB Output is correct
34 Correct 201 ms 3928 KB Output is correct
35 Correct 198 ms 4128 KB Output is correct
36 Correct 210 ms 4184 KB Output is correct
37 Correct 205 ms 3932 KB Output is correct
38 Correct 203 ms 4184 KB Output is correct
39 Correct 17 ms 7772 KB Output is correct
40 Correct 17 ms 7768 KB Output is correct
41 Correct 17 ms 7772 KB Output is correct
42 Correct 6 ms 1444 KB Output is correct
43 Correct 4 ms 1116 KB Output is correct
44 Correct 8 ms 1628 KB Output is correct
45 Correct 6 ms 1116 KB Output is correct
46 Correct 5 ms 1272 KB Output is correct
47 Correct 8 ms 1672 KB Output is correct
48 Execution timed out 1544 ms 13148 KB Time limit exceeded
49 Halted 0 ms 0 KB -