Submission #730651

# Submission time Handle Problem Language Result Execution time Memory
730651 2023-04-26T08:38:03 Z t6twotwo Painting Walls (APIO20_paint) C++17
28 / 100
1500 ms 12352 KB
#include "paint.h"
#include <bits/stdc++.h>
using namespace std;
constexpr int inf = 1E6;
int minimumInstructions(int N, int M, int K, vector<int> C, vector<int> A, vector<vector<int>> B) {
    vector<vector<int>> f(K);
    for (int i = 0; i < M; i++) {
        for (int x : B[i]) {
            f[x].push_back(i);
        }
    }
    vector<int> dp(N + 1, inf);
    dp[0] = 0;
    for (int i = M - 1; i < N; i++) {
        auto mn = inf;
        vector<int> cnt(M);
        for (int j = 1; j <= M; j++) {
            for (int k : f[C[i - M + j]]) {
                cnt[(k - j + M) % M]++;
            }
            mn = min(mn, dp[i - M + j]);
        }
        if (count(cnt.begin(), cnt.end(), M)) {
            dp[i + 1] = min(dp[i + 1], mn + 1);
        }
    }
    return dp[N] == inf ? -1 : dp[N];
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 300 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 3 ms 2644 KB Output is correct
14 Correct 3 ms 2644 KB Output is correct
15 Correct 3 ms 2644 KB Output is correct
16 Correct 3 ms 2644 KB Output is correct
17 Correct 3 ms 2616 KB Output is correct
18 Correct 3 ms 2644 KB Output is correct
19 Correct 2 ms 2644 KB Output is correct
20 Correct 2 ms 2644 KB Output is correct
21 Correct 2 ms 2644 KB Output is correct
22 Correct 23 ms 6612 KB Output is correct
23 Correct 19 ms 6688 KB Output is correct
24 Correct 28 ms 6580 KB Output is correct
25 Correct 3 ms 468 KB Output is correct
26 Correct 4 ms 468 KB Output is correct
27 Correct 4 ms 468 KB Output is correct
28 Correct 4 ms 468 KB Output is correct
29 Correct 4 ms 468 KB Output is correct
30 Correct 5 ms 468 KB Output is correct
31 Correct 899 ms 3928 KB Output is correct
32 Correct 900 ms 3924 KB Output is correct
33 Correct 884 ms 3924 KB Output is correct
34 Correct 833 ms 3928 KB Output is correct
35 Correct 874 ms 3928 KB Output is correct
36 Correct 920 ms 3932 KB Output is correct
37 Correct 1163 ms 7088 KB Output is correct
38 Correct 1008 ms 7180 KB Output is correct
39 Correct 1184 ms 7084 KB Output is correct
40 Correct 16 ms 1492 KB Output is correct
41 Correct 8 ms 980 KB Output is correct
42 Correct 16 ms 1492 KB Output is correct
43 Correct 13 ms 1108 KB Output is correct
44 Correct 10 ms 1040 KB Output is correct
45 Correct 18 ms 1508 KB Output is correct
46 Execution timed out 1567 ms 12352 KB Time limit exceeded
47 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 300 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 3 ms 2644 KB Output is correct
14 Correct 3 ms 2644 KB Output is correct
15 Correct 3 ms 2644 KB Output is correct
16 Correct 3 ms 2644 KB Output is correct
17 Correct 3 ms 2616 KB Output is correct
18 Correct 3 ms 2644 KB Output is correct
19 Correct 2 ms 2644 KB Output is correct
20 Correct 2 ms 2644 KB Output is correct
21 Correct 2 ms 2644 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 296 KB Output is correct
25 Correct 2 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 2 ms 304 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 2 ms 296 KB Output is correct
31 Correct 1 ms 212 KB Output is correct
32 Correct 2 ms 212 KB Output is correct
33 Correct 2 ms 2356 KB Output is correct
34 Correct 2 ms 1748 KB Output is correct
35 Correct 1 ms 1576 KB Output is correct
36 Correct 2 ms 2608 KB Output is correct
37 Correct 2 ms 2132 KB Output is correct
38 Correct 2 ms 2388 KB Output is correct
39 Correct 1 ms 212 KB Output is correct
40 Correct 2 ms 2132 KB Output is correct
41 Correct 1 ms 304 KB Output is correct
42 Correct 2 ms 2480 KB Output is correct
43 Correct 2 ms 2388 KB Output is correct
44 Correct 1 ms 212 KB Output is correct
45 Correct 4 ms 212 KB Output is correct
46 Correct 4 ms 212 KB Output is correct
47 Correct 3 ms 212 KB Output is correct
48 Correct 4 ms 212 KB Output is correct
49 Correct 3 ms 300 KB Output is correct
50 Correct 3 ms 2644 KB Output is correct
51 Correct 3 ms 2644 KB Output is correct
52 Correct 3 ms 2604 KB Output is correct
53 Correct 3 ms 2608 KB Output is correct
54 Correct 3 ms 2644 KB Output is correct
55 Correct 3 ms 2608 KB Output is correct
56 Correct 2 ms 2644 KB Output is correct
57 Correct 2 ms 340 KB Output is correct
58 Correct 2 ms 2612 KB Output is correct
59 Correct 2 ms 340 KB Output is correct
60 Correct 2 ms 2644 KB Output is correct
61 Correct 2 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 300 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 3 ms 2644 KB Output is correct
16 Correct 3 ms 2644 KB Output is correct
17 Correct 3 ms 2644 KB Output is correct
18 Correct 3 ms 2644 KB Output is correct
19 Correct 3 ms 2616 KB Output is correct
20 Correct 3 ms 2644 KB Output is correct
21 Correct 2 ms 2644 KB Output is correct
22 Correct 2 ms 2644 KB Output is correct
23 Correct 2 ms 2644 KB Output is correct
24 Correct 23 ms 6612 KB Output is correct
25 Correct 19 ms 6688 KB Output is correct
26 Correct 28 ms 6580 KB Output is correct
27 Correct 1 ms 296 KB Output is correct
28 Correct 2 ms 212 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 2 ms 304 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
33 Correct 2 ms 296 KB Output is correct
34 Correct 1 ms 212 KB Output is correct
35 Correct 2 ms 212 KB Output is correct
36 Correct 2 ms 2356 KB Output is correct
37 Correct 2 ms 1748 KB Output is correct
38 Correct 1 ms 1576 KB Output is correct
39 Correct 2 ms 2608 KB Output is correct
40 Correct 2 ms 2132 KB Output is correct
41 Correct 2 ms 2388 KB Output is correct
42 Correct 1 ms 212 KB Output is correct
43 Correct 2 ms 2132 KB Output is correct
44 Correct 1 ms 304 KB Output is correct
45 Correct 2 ms 2480 KB Output is correct
46 Correct 2 ms 2388 KB Output is correct
47 Correct 1 ms 212 KB Output is correct
48 Correct 4 ms 212 KB Output is correct
49 Correct 4 ms 212 KB Output is correct
50 Correct 3 ms 212 KB Output is correct
51 Correct 4 ms 212 KB Output is correct
52 Correct 3 ms 300 KB Output is correct
53 Correct 3 ms 2644 KB Output is correct
54 Correct 3 ms 2644 KB Output is correct
55 Correct 3 ms 2604 KB Output is correct
56 Correct 3 ms 2608 KB Output is correct
57 Correct 3 ms 2644 KB Output is correct
58 Correct 3 ms 2608 KB Output is correct
59 Correct 2 ms 2644 KB Output is correct
60 Correct 2 ms 340 KB Output is correct
61 Correct 2 ms 2612 KB Output is correct
62 Correct 2 ms 340 KB Output is correct
63 Correct 2 ms 2644 KB Output is correct
64 Correct 2 ms 340 KB Output is correct
65 Correct 18 ms 212 KB Output is correct
66 Correct 7 ms 304 KB Output is correct
67 Correct 43 ms 332 KB Output is correct
68 Correct 16 ms 212 KB Output is correct
69 Correct 32 ms 296 KB Output is correct
70 Correct 12 ms 2516 KB Output is correct
71 Correct 13 ms 2132 KB Output is correct
72 Correct 10 ms 1876 KB Output is correct
73 Correct 3 ms 2004 KB Output is correct
74 Correct 10 ms 2388 KB Output is correct
75 Correct 9 ms 2744 KB Output is correct
76 Correct 20 ms 4740 KB Output is correct
77 Correct 18 ms 5460 KB Output is correct
78 Correct 26 ms 6072 KB Output is correct
79 Correct 84 ms 312 KB Output is correct
80 Correct 85 ms 316 KB Output is correct
81 Correct 84 ms 312 KB Output is correct
82 Correct 82 ms 212 KB Output is correct
83 Correct 77 ms 340 KB Output is correct
84 Correct 15 ms 2900 KB Output is correct
85 Correct 16 ms 2872 KB Output is correct
86 Correct 17 ms 2872 KB Output is correct
87 Correct 16 ms 2928 KB Output is correct
88 Correct 17 ms 2956 KB Output is correct
89 Correct 16 ms 2900 KB Output is correct
90 Correct 27 ms 6436 KB Output is correct
91 Correct 32 ms 6476 KB Output is correct
92 Correct 28 ms 6476 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 300 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 3 ms 2644 KB Output is correct
16 Correct 3 ms 2644 KB Output is correct
17 Correct 3 ms 2644 KB Output is correct
18 Correct 3 ms 2644 KB Output is correct
19 Correct 3 ms 2616 KB Output is correct
20 Correct 3 ms 2644 KB Output is correct
21 Correct 2 ms 2644 KB Output is correct
22 Correct 2 ms 2644 KB Output is correct
23 Correct 2 ms 2644 KB Output is correct
24 Correct 23 ms 6612 KB Output is correct
25 Correct 19 ms 6688 KB Output is correct
26 Correct 28 ms 6580 KB Output is correct
27 Correct 3 ms 468 KB Output is correct
28 Correct 4 ms 468 KB Output is correct
29 Correct 4 ms 468 KB Output is correct
30 Correct 4 ms 468 KB Output is correct
31 Correct 4 ms 468 KB Output is correct
32 Correct 5 ms 468 KB Output is correct
33 Correct 899 ms 3928 KB Output is correct
34 Correct 900 ms 3924 KB Output is correct
35 Correct 884 ms 3924 KB Output is correct
36 Correct 833 ms 3928 KB Output is correct
37 Correct 874 ms 3928 KB Output is correct
38 Correct 920 ms 3932 KB Output is correct
39 Correct 1163 ms 7088 KB Output is correct
40 Correct 1008 ms 7180 KB Output is correct
41 Correct 1184 ms 7084 KB Output is correct
42 Correct 1 ms 296 KB Output is correct
43 Correct 2 ms 212 KB Output is correct
44 Correct 1 ms 212 KB Output is correct
45 Correct 1 ms 212 KB Output is correct
46 Correct 2 ms 304 KB Output is correct
47 Correct 1 ms 212 KB Output is correct
48 Correct 2 ms 296 KB Output is correct
49 Correct 1 ms 212 KB Output is correct
50 Correct 2 ms 212 KB Output is correct
51 Correct 2 ms 2356 KB Output is correct
52 Correct 2 ms 1748 KB Output is correct
53 Correct 1 ms 1576 KB Output is correct
54 Correct 2 ms 2608 KB Output is correct
55 Correct 2 ms 2132 KB Output is correct
56 Correct 2 ms 2388 KB Output is correct
57 Correct 1 ms 212 KB Output is correct
58 Correct 2 ms 2132 KB Output is correct
59 Correct 1 ms 304 KB Output is correct
60 Correct 2 ms 2480 KB Output is correct
61 Correct 2 ms 2388 KB Output is correct
62 Correct 1 ms 212 KB Output is correct
63 Correct 4 ms 212 KB Output is correct
64 Correct 4 ms 212 KB Output is correct
65 Correct 3 ms 212 KB Output is correct
66 Correct 4 ms 212 KB Output is correct
67 Correct 3 ms 300 KB Output is correct
68 Correct 3 ms 2644 KB Output is correct
69 Correct 3 ms 2644 KB Output is correct
70 Correct 3 ms 2604 KB Output is correct
71 Correct 3 ms 2608 KB Output is correct
72 Correct 3 ms 2644 KB Output is correct
73 Correct 3 ms 2608 KB Output is correct
74 Correct 2 ms 2644 KB Output is correct
75 Correct 2 ms 340 KB Output is correct
76 Correct 2 ms 2612 KB Output is correct
77 Correct 2 ms 340 KB Output is correct
78 Correct 2 ms 2644 KB Output is correct
79 Correct 2 ms 340 KB Output is correct
80 Correct 18 ms 212 KB Output is correct
81 Correct 7 ms 304 KB Output is correct
82 Correct 43 ms 332 KB Output is correct
83 Correct 16 ms 212 KB Output is correct
84 Correct 32 ms 296 KB Output is correct
85 Correct 12 ms 2516 KB Output is correct
86 Correct 13 ms 2132 KB Output is correct
87 Correct 10 ms 1876 KB Output is correct
88 Correct 3 ms 2004 KB Output is correct
89 Correct 10 ms 2388 KB Output is correct
90 Correct 9 ms 2744 KB Output is correct
91 Correct 20 ms 4740 KB Output is correct
92 Correct 18 ms 5460 KB Output is correct
93 Correct 26 ms 6072 KB Output is correct
94 Correct 84 ms 312 KB Output is correct
95 Correct 85 ms 316 KB Output is correct
96 Correct 84 ms 312 KB Output is correct
97 Correct 82 ms 212 KB Output is correct
98 Correct 77 ms 340 KB Output is correct
99 Correct 15 ms 2900 KB Output is correct
100 Correct 16 ms 2872 KB Output is correct
101 Correct 17 ms 2872 KB Output is correct
102 Correct 16 ms 2928 KB Output is correct
103 Correct 17 ms 2956 KB Output is correct
104 Correct 16 ms 2900 KB Output is correct
105 Correct 27 ms 6436 KB Output is correct
106 Correct 32 ms 6476 KB Output is correct
107 Correct 28 ms 6476 KB Output is correct
108 Correct 4 ms 468 KB Output is correct
109 Execution timed out 1580 ms 468 KB Time limit exceeded
110 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 300 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 3 ms 2644 KB Output is correct
16 Correct 3 ms 2644 KB Output is correct
17 Correct 3 ms 2644 KB Output is correct
18 Correct 3 ms 2644 KB Output is correct
19 Correct 3 ms 2616 KB Output is correct
20 Correct 3 ms 2644 KB Output is correct
21 Correct 2 ms 2644 KB Output is correct
22 Correct 2 ms 2644 KB Output is correct
23 Correct 2 ms 2644 KB Output is correct
24 Correct 23 ms 6612 KB Output is correct
25 Correct 19 ms 6688 KB Output is correct
26 Correct 28 ms 6580 KB Output is correct
27 Correct 3 ms 468 KB Output is correct
28 Correct 4 ms 468 KB Output is correct
29 Correct 4 ms 468 KB Output is correct
30 Correct 4 ms 468 KB Output is correct
31 Correct 4 ms 468 KB Output is correct
32 Correct 5 ms 468 KB Output is correct
33 Correct 899 ms 3928 KB Output is correct
34 Correct 900 ms 3924 KB Output is correct
35 Correct 884 ms 3924 KB Output is correct
36 Correct 833 ms 3928 KB Output is correct
37 Correct 874 ms 3928 KB Output is correct
38 Correct 920 ms 3932 KB Output is correct
39 Correct 1163 ms 7088 KB Output is correct
40 Correct 1008 ms 7180 KB Output is correct
41 Correct 1184 ms 7084 KB Output is correct
42 Correct 16 ms 1492 KB Output is correct
43 Correct 8 ms 980 KB Output is correct
44 Correct 16 ms 1492 KB Output is correct
45 Correct 13 ms 1108 KB Output is correct
46 Correct 10 ms 1040 KB Output is correct
47 Correct 18 ms 1508 KB Output is correct
48 Execution timed out 1567 ms 12352 KB Time limit exceeded
49 Halted 0 ms 0 KB -