Submission #810202

# Submission time Handle Problem Language Result Execution time Memory
810202 2023-08-06T06:30:04 Z boyliguanhan Painting Walls (APIO20_paint) C++17
28 / 100
1500 ms 11004 KB
#include "paint.h"

#include <bits/stdc++.h>
using namespace std;
int lseg1[200100], lseg2[200100];
vector<int> liked_by[200100];
int dp[200100]{}, valid_i[200100]{};
int minimumInstructions(int N, int M, int K, vector<int> C, vector<int> A, vector<vector<int>> B) {
    for(int i = 0; i < K; i++) liked_by[i].clear();
    multiset<int> st;
    for(int i = 0; i < M; i++)
        for(int color: B[i])
            liked_by[color].push_back(i);
    for(int i = N; i--;) {
        for(auto j: liked_by[C[i]]) {
            lseg1[j] = 1+lseg2[(j+1)%M];
            if(lseg1[j]>=M) valid_i[i]=1;
        }
        swap(lseg1, lseg2);
        if(i<N-1)
            for(auto j:liked_by[C[i+1]])
                lseg1[j]=0;
    }
    for(int i = 0; i < M; i++) st.insert(0);
    for(int i = N; i--;) {
        dp[i]=1e9;
        if(valid_i[i])
            dp[i] = 1+*st.begin();
        st.insert(dp[i]);
        st.erase(st.find(dp[i+M]));
    }
    return (dp[0]<1e9?dp[0]:-1);
}
# Verdict Execution time Memory Grader output
1 Correct 4 ms 6484 KB Output is correct
2 Correct 3 ms 6488 KB Output is correct
3 Correct 3 ms 6552 KB Output is correct
4 Correct 4 ms 6484 KB Output is correct
5 Correct 3 ms 6484 KB Output is correct
6 Correct 4 ms 6484 KB Output is correct
7 Correct 69 ms 6556 KB Output is correct
8 Correct 66 ms 6560 KB Output is correct
9 Correct 67 ms 6564 KB Output is correct
10 Correct 66 ms 6552 KB Output is correct
11 Correct 69 ms 6556 KB Output is correct
12 Correct 66 ms 6564 KB Output is correct
13 Correct 70 ms 6612 KB Output is correct
14 Correct 68 ms 6612 KB Output is correct
15 Correct 69 ms 6612 KB Output is correct
16 Correct 67 ms 6612 KB Output is correct
17 Correct 67 ms 6596 KB Output is correct
18 Correct 66 ms 6604 KB Output is correct
19 Correct 72 ms 6620 KB Output is correct
20 Correct 72 ms 6616 KB Output is correct
21 Correct 67 ms 6616 KB Output is correct
22 Correct 91 ms 10992 KB Output is correct
23 Correct 81 ms 10996 KB Output is correct
24 Correct 86 ms 11004 KB Output is correct
25 Execution timed out 1575 ms 6900 KB Time limit exceeded
26 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 6484 KB Output is correct
2 Correct 3 ms 6488 KB Output is correct
3 Correct 3 ms 6552 KB Output is correct
4 Correct 4 ms 6484 KB Output is correct
5 Correct 3 ms 6484 KB Output is correct
6 Correct 4 ms 6484 KB Output is correct
7 Correct 69 ms 6556 KB Output is correct
8 Correct 66 ms 6560 KB Output is correct
9 Correct 67 ms 6564 KB Output is correct
10 Correct 66 ms 6552 KB Output is correct
11 Correct 69 ms 6556 KB Output is correct
12 Correct 66 ms 6564 KB Output is correct
13 Correct 70 ms 6612 KB Output is correct
14 Correct 68 ms 6612 KB Output is correct
15 Correct 69 ms 6612 KB Output is correct
16 Correct 67 ms 6612 KB Output is correct
17 Correct 67 ms 6596 KB Output is correct
18 Correct 66 ms 6604 KB Output is correct
19 Correct 72 ms 6620 KB Output is correct
20 Correct 72 ms 6616 KB Output is correct
21 Correct 67 ms 6616 KB Output is correct
22 Correct 5 ms 6548 KB Output is correct
23 Correct 4 ms 6484 KB Output is correct
24 Correct 4 ms 6544 KB Output is correct
25 Correct 4 ms 6484 KB Output is correct
26 Correct 5 ms 6484 KB Output is correct
27 Correct 44 ms 6556 KB Output is correct
28 Correct 44 ms 6560 KB Output is correct
29 Correct 35 ms 6584 KB Output is correct
30 Correct 47 ms 6572 KB Output is correct
31 Correct 63 ms 6564 KB Output is correct
32 Correct 56 ms 6556 KB Output is correct
33 Correct 55 ms 6592 KB Output is correct
34 Correct 59 ms 6552 KB Output is correct
35 Correct 41 ms 6596 KB Output is correct
36 Correct 51 ms 6592 KB Output is correct
37 Correct 46 ms 6604 KB Output is correct
38 Correct 44 ms 6612 KB Output is correct
39 Correct 43 ms 6560 KB Output is correct
40 Correct 44 ms 6612 KB Output is correct
41 Correct 44 ms 6600 KB Output is correct
42 Correct 59 ms 6592 KB Output is correct
43 Correct 45 ms 6588 KB Output is correct
44 Correct 75 ms 6564 KB Output is correct
45 Correct 66 ms 6560 KB Output is correct
46 Correct 80 ms 6564 KB Output is correct
47 Correct 66 ms 6544 KB Output is correct
48 Correct 92 ms 6564 KB Output is correct
49 Correct 66 ms 6572 KB Output is correct
50 Correct 71 ms 6612 KB Output is correct
51 Correct 78 ms 6596 KB Output is correct
52 Correct 67 ms 6616 KB Output is correct
53 Correct 72 ms 6596 KB Output is correct
54 Correct 78 ms 6600 KB Output is correct
55 Correct 69 ms 6600 KB Output is correct
56 Correct 69 ms 6620 KB Output is correct
57 Correct 71 ms 6592 KB Output is correct
58 Correct 67 ms 6620 KB Output is correct
59 Correct 79 ms 6612 KB Output is correct
60 Correct 76 ms 6620 KB Output is correct
61 Correct 69 ms 6548 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 6548 KB Output is correct
2 Correct 4 ms 6484 KB Output is correct
3 Correct 4 ms 6484 KB Output is correct
4 Correct 3 ms 6488 KB Output is correct
5 Correct 3 ms 6552 KB Output is correct
6 Correct 4 ms 6484 KB Output is correct
7 Correct 3 ms 6484 KB Output is correct
8 Correct 4 ms 6484 KB Output is correct
9 Correct 69 ms 6556 KB Output is correct
10 Correct 66 ms 6560 KB Output is correct
11 Correct 67 ms 6564 KB Output is correct
12 Correct 66 ms 6552 KB Output is correct
13 Correct 69 ms 6556 KB Output is correct
14 Correct 66 ms 6564 KB Output is correct
15 Correct 70 ms 6612 KB Output is correct
16 Correct 68 ms 6612 KB Output is correct
17 Correct 69 ms 6612 KB Output is correct
18 Correct 67 ms 6612 KB Output is correct
19 Correct 67 ms 6596 KB Output is correct
20 Correct 66 ms 6604 KB Output is correct
21 Correct 72 ms 6620 KB Output is correct
22 Correct 72 ms 6616 KB Output is correct
23 Correct 67 ms 6616 KB Output is correct
24 Correct 91 ms 10992 KB Output is correct
25 Correct 81 ms 10996 KB Output is correct
26 Correct 86 ms 11004 KB Output is correct
27 Correct 4 ms 6544 KB Output is correct
28 Correct 4 ms 6484 KB Output is correct
29 Correct 5 ms 6484 KB Output is correct
30 Correct 44 ms 6556 KB Output is correct
31 Correct 44 ms 6560 KB Output is correct
32 Correct 35 ms 6584 KB Output is correct
33 Correct 47 ms 6572 KB Output is correct
34 Correct 63 ms 6564 KB Output is correct
35 Correct 56 ms 6556 KB Output is correct
36 Correct 55 ms 6592 KB Output is correct
37 Correct 59 ms 6552 KB Output is correct
38 Correct 41 ms 6596 KB Output is correct
39 Correct 51 ms 6592 KB Output is correct
40 Correct 46 ms 6604 KB Output is correct
41 Correct 44 ms 6612 KB Output is correct
42 Correct 43 ms 6560 KB Output is correct
43 Correct 44 ms 6612 KB Output is correct
44 Correct 44 ms 6600 KB Output is correct
45 Correct 59 ms 6592 KB Output is correct
46 Correct 45 ms 6588 KB Output is correct
47 Correct 75 ms 6564 KB Output is correct
48 Correct 66 ms 6560 KB Output is correct
49 Correct 80 ms 6564 KB Output is correct
50 Correct 66 ms 6544 KB Output is correct
51 Correct 92 ms 6564 KB Output is correct
52 Correct 66 ms 6572 KB Output is correct
53 Correct 71 ms 6612 KB Output is correct
54 Correct 78 ms 6596 KB Output is correct
55 Correct 67 ms 6616 KB Output is correct
56 Correct 72 ms 6596 KB Output is correct
57 Correct 78 ms 6600 KB Output is correct
58 Correct 69 ms 6600 KB Output is correct
59 Correct 69 ms 6620 KB Output is correct
60 Correct 71 ms 6592 KB Output is correct
61 Correct 67 ms 6620 KB Output is correct
62 Correct 79 ms 6612 KB Output is correct
63 Correct 76 ms 6620 KB Output is correct
64 Correct 69 ms 6548 KB Output is correct
65 Correct 39 ms 6572 KB Output is correct
66 Correct 66 ms 6572 KB Output is correct
67 Correct 67 ms 6484 KB Output is correct
68 Correct 68 ms 6568 KB Output is correct
69 Correct 68 ms 6572 KB Output is correct
70 Correct 65 ms 6796 KB Output is correct
71 Correct 67 ms 6816 KB Output is correct
72 Correct 57 ms 6800 KB Output is correct
73 Correct 57 ms 6712 KB Output is correct
74 Correct 51 ms 6804 KB Output is correct
75 Correct 50 ms 6780 KB Output is correct
76 Correct 59 ms 9720 KB Output is correct
77 Correct 63 ms 10164 KB Output is correct
78 Correct 72 ms 10564 KB Output is correct
79 Correct 81 ms 6580 KB Output is correct
80 Correct 67 ms 6580 KB Output is correct
81 Correct 69 ms 6584 KB Output is correct
82 Correct 83 ms 6612 KB Output is correct
83 Correct 74 ms 6584 KB Output is correct
84 Correct 71 ms 6876 KB Output is correct
85 Correct 83 ms 6868 KB Output is correct
86 Correct 85 ms 6872 KB Output is correct
87 Correct 69 ms 6876 KB Output is correct
88 Correct 74 ms 6868 KB Output is correct
89 Correct 71 ms 6872 KB Output is correct
90 Correct 96 ms 10956 KB Output is correct
91 Correct 104 ms 10732 KB Output is correct
92 Correct 90 ms 10836 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 6548 KB Output is correct
2 Correct 4 ms 6484 KB Output is correct
3 Correct 4 ms 6484 KB Output is correct
4 Correct 3 ms 6488 KB Output is correct
5 Correct 3 ms 6552 KB Output is correct
6 Correct 4 ms 6484 KB Output is correct
7 Correct 3 ms 6484 KB Output is correct
8 Correct 4 ms 6484 KB Output is correct
9 Correct 69 ms 6556 KB Output is correct
10 Correct 66 ms 6560 KB Output is correct
11 Correct 67 ms 6564 KB Output is correct
12 Correct 66 ms 6552 KB Output is correct
13 Correct 69 ms 6556 KB Output is correct
14 Correct 66 ms 6564 KB Output is correct
15 Correct 70 ms 6612 KB Output is correct
16 Correct 68 ms 6612 KB Output is correct
17 Correct 69 ms 6612 KB Output is correct
18 Correct 67 ms 6612 KB Output is correct
19 Correct 67 ms 6596 KB Output is correct
20 Correct 66 ms 6604 KB Output is correct
21 Correct 72 ms 6620 KB Output is correct
22 Correct 72 ms 6616 KB Output is correct
23 Correct 67 ms 6616 KB Output is correct
24 Correct 91 ms 10992 KB Output is correct
25 Correct 81 ms 10996 KB Output is correct
26 Correct 86 ms 11004 KB Output is correct
27 Execution timed out 1575 ms 6900 KB Time limit exceeded
28 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 6548 KB Output is correct
2 Correct 4 ms 6484 KB Output is correct
3 Correct 4 ms 6484 KB Output is correct
4 Correct 3 ms 6488 KB Output is correct
5 Correct 3 ms 6552 KB Output is correct
6 Correct 4 ms 6484 KB Output is correct
7 Correct 3 ms 6484 KB Output is correct
8 Correct 4 ms 6484 KB Output is correct
9 Correct 69 ms 6556 KB Output is correct
10 Correct 66 ms 6560 KB Output is correct
11 Correct 67 ms 6564 KB Output is correct
12 Correct 66 ms 6552 KB Output is correct
13 Correct 69 ms 6556 KB Output is correct
14 Correct 66 ms 6564 KB Output is correct
15 Correct 70 ms 6612 KB Output is correct
16 Correct 68 ms 6612 KB Output is correct
17 Correct 69 ms 6612 KB Output is correct
18 Correct 67 ms 6612 KB Output is correct
19 Correct 67 ms 6596 KB Output is correct
20 Correct 66 ms 6604 KB Output is correct
21 Correct 72 ms 6620 KB Output is correct
22 Correct 72 ms 6616 KB Output is correct
23 Correct 67 ms 6616 KB Output is correct
24 Correct 91 ms 10992 KB Output is correct
25 Correct 81 ms 10996 KB Output is correct
26 Correct 86 ms 11004 KB Output is correct
27 Execution timed out 1575 ms 6900 KB Time limit exceeded
28 Halted 0 ms 0 KB -