Submission #864123

# Submission time Handle Problem Language Result Execution time Memory
864123 2023-10-22T06:24:46 Z jk410 Painting Walls (APIO20_paint) C++17
51 / 100
189 ms 162384 KB
#include "paint.h"
#include <vector>
using namespace std;
vector<int> Walls[100000];//색이 i인 벽들
int D[2000][20000];//일꾼 i가 벽 j를 칠할 수 있다면 D[(i-j)%M][j]=1
int minimumInstructions(int N, int M, int K, std::vector<int> C,std::vector<int> A, std::vector<std::vector<int>> B){
    for (int i=0; i<N; i++)
        Walls[C[i]].push_back(i);
    for (int i=0; i<M; i++){
        for (int j:B[i]){
            for (int k:Walls[j])
                D[((i-k)%M+M)%M][k]=1;
        }
    }
    for (int i=0; i<M; i++){
        for (int j=1; j<N; j++)
            D[i][j]+=D[i][j-1];
    }
    vector<int> v;
    for (int i=M-1; i<N; i++){
        for (int j=0; j<M; j++){
            if (D[j][i]-(i<M?0:D[j][i-M])==M){
                v.push_back(i);
                break;
            }
        }
    }
    int ret=0,prev=-1;
    for (int i=0; i<(int)v.size(); i++){
        if (i==(int)v.size()-1||v[i+1]>prev+M){
            if (v[i]>prev+M)
                return -1;
            ret++;
            prev=v[i];
        }
    }
    if (prev!=N-1)
        return -1;
    return ret;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4188 KB Output is correct
2 Correct 1 ms 4188 KB Output is correct
3 Correct 1 ms 4188 KB Output is correct
4 Correct 1 ms 4188 KB Output is correct
5 Correct 1 ms 4328 KB Output is correct
6 Correct 1 ms 4188 KB Output is correct
7 Correct 1 ms 4184 KB Output is correct
8 Correct 1 ms 4188 KB Output is correct
9 Correct 1 ms 4188 KB Output is correct
10 Correct 1 ms 4188 KB Output is correct
11 Correct 1 ms 4444 KB Output is correct
12 Correct 1 ms 4444 KB Output is correct
13 Correct 2 ms 7516 KB Output is correct
14 Correct 2 ms 7516 KB Output is correct
15 Correct 3 ms 7496 KB Output is correct
16 Correct 2 ms 7516 KB Output is correct
17 Correct 2 ms 7516 KB Output is correct
18 Correct 2 ms 7516 KB Output is correct
19 Correct 3 ms 14940 KB Output is correct
20 Correct 3 ms 13148 KB Output is correct
21 Correct 3 ms 15020 KB Output is correct
22 Correct 11 ms 22192 KB Output is correct
23 Correct 11 ms 22108 KB Output is correct
24 Correct 11 ms 22108 KB Output is correct
25 Correct 3 ms 4956 KB Output is correct
26 Correct 3 ms 4772 KB Output is correct
27 Correct 3 ms 4956 KB Output is correct
28 Correct 3 ms 4956 KB Output is correct
29 Correct 3 ms 4956 KB Output is correct
30 Correct 3 ms 5112 KB Output is correct
31 Correct 121 ms 160592 KB Output is correct
32 Correct 167 ms 160596 KB Output is correct
33 Correct 167 ms 160596 KB Output is correct
34 Correct 178 ms 160732 KB Output is correct
35 Correct 160 ms 160676 KB Output is correct
36 Correct 174 ms 160596 KB Output is correct
37 Correct 181 ms 161876 KB Output is correct
38 Correct 180 ms 161620 KB Output is correct
39 Correct 183 ms 161620 KB Output is correct
40 Correct 9 ms 6612 KB Output is correct
41 Correct 6 ms 5724 KB Output is correct
42 Correct 10 ms 6360 KB Output is correct
43 Correct 7 ms 5720 KB Output is correct
44 Correct 7 ms 5724 KB Output is correct
45 Correct 11 ms 6724 KB Output is correct
46 Runtime error 38 ms 27948 KB Execution killed with signal 11
47 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4188 KB Output is correct
2 Correct 1 ms 4188 KB Output is correct
3 Correct 1 ms 4188 KB Output is correct
4 Correct 1 ms 4188 KB Output is correct
5 Correct 1 ms 4328 KB Output is correct
6 Correct 1 ms 4188 KB Output is correct
7 Correct 1 ms 4184 KB Output is correct
8 Correct 1 ms 4188 KB Output is correct
9 Correct 1 ms 4188 KB Output is correct
10 Correct 1 ms 4188 KB Output is correct
11 Correct 1 ms 4444 KB Output is correct
12 Correct 1 ms 4444 KB Output is correct
13 Correct 2 ms 7516 KB Output is correct
14 Correct 2 ms 7516 KB Output is correct
15 Correct 3 ms 7496 KB Output is correct
16 Correct 2 ms 7516 KB Output is correct
17 Correct 2 ms 7516 KB Output is correct
18 Correct 2 ms 7516 KB Output is correct
19 Correct 3 ms 14940 KB Output is correct
20 Correct 3 ms 13148 KB Output is correct
21 Correct 3 ms 15020 KB Output is correct
22 Correct 1 ms 4188 KB Output is correct
23 Correct 1 ms 4188 KB Output is correct
24 Correct 2 ms 4188 KB Output is correct
25 Correct 1 ms 4188 KB Output is correct
26 Correct 1 ms 4188 KB Output is correct
27 Correct 1 ms 4188 KB Output is correct
28 Correct 2 ms 6492 KB Output is correct
29 Correct 1 ms 6492 KB Output is correct
30 Correct 2 ms 6492 KB Output is correct
31 Correct 1 ms 4420 KB Output is correct
32 Correct 2 ms 8540 KB Output is correct
33 Correct 2 ms 7260 KB Output is correct
34 Correct 2 ms 5212 KB Output is correct
35 Correct 2 ms 7004 KB Output is correct
36 Correct 2 ms 7004 KB Output is correct
37 Correct 2 ms 7260 KB Output is correct
38 Correct 2 ms 4340 KB Output is correct
39 Correct 2 ms 4444 KB Output is correct
40 Correct 2 ms 12892 KB Output is correct
41 Correct 3 ms 16732 KB Output is correct
42 Correct 2 ms 8540 KB Output is correct
43 Correct 2 ms 8540 KB Output is correct
44 Correct 1 ms 4416 KB Output is correct
45 Correct 2 ms 6492 KB Output is correct
46 Correct 2 ms 8540 KB Output is correct
47 Correct 2 ms 8540 KB Output is correct
48 Correct 2 ms 8536 KB Output is correct
49 Correct 2 ms 8540 KB Output is correct
50 Correct 2 ms 7516 KB Output is correct
51 Correct 2 ms 7516 KB Output is correct
52 Correct 2 ms 7556 KB Output is correct
53 Correct 2 ms 7516 KB Output is correct
54 Correct 2 ms 7516 KB Output is correct
55 Correct 2 ms 7516 KB Output is correct
56 Correct 3 ms 13148 KB Output is correct
57 Correct 4 ms 20828 KB Output is correct
58 Correct 3 ms 11100 KB Output is correct
59 Correct 3 ms 20828 KB Output is correct
60 Correct 3 ms 7516 KB Output is correct
61 Correct 3 ms 20828 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4188 KB Output is correct
2 Correct 1 ms 4188 KB Output is correct
3 Correct 1 ms 4188 KB Output is correct
4 Correct 1 ms 4188 KB Output is correct
5 Correct 1 ms 4188 KB Output is correct
6 Correct 1 ms 4188 KB Output is correct
7 Correct 1 ms 4328 KB Output is correct
8 Correct 1 ms 4188 KB Output is correct
9 Correct 1 ms 4184 KB Output is correct
10 Correct 1 ms 4188 KB Output is correct
11 Correct 1 ms 4188 KB Output is correct
12 Correct 1 ms 4188 KB Output is correct
13 Correct 1 ms 4444 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 2 ms 7516 KB Output is correct
16 Correct 2 ms 7516 KB Output is correct
17 Correct 3 ms 7496 KB Output is correct
18 Correct 2 ms 7516 KB Output is correct
19 Correct 2 ms 7516 KB Output is correct
20 Correct 2 ms 7516 KB Output is correct
21 Correct 3 ms 14940 KB Output is correct
22 Correct 3 ms 13148 KB Output is correct
23 Correct 3 ms 15020 KB Output is correct
24 Correct 11 ms 22192 KB Output is correct
25 Correct 11 ms 22108 KB Output is correct
26 Correct 11 ms 22108 KB Output is correct
27 Correct 2 ms 4188 KB Output is correct
28 Correct 1 ms 4188 KB Output is correct
29 Correct 1 ms 4188 KB Output is correct
30 Correct 1 ms 4188 KB Output is correct
31 Correct 2 ms 6492 KB Output is correct
32 Correct 1 ms 6492 KB Output is correct
33 Correct 2 ms 6492 KB Output is correct
34 Correct 1 ms 4420 KB Output is correct
35 Correct 2 ms 8540 KB Output is correct
36 Correct 2 ms 7260 KB Output is correct
37 Correct 2 ms 5212 KB Output is correct
38 Correct 2 ms 7004 KB Output is correct
39 Correct 2 ms 7004 KB Output is correct
40 Correct 2 ms 7260 KB Output is correct
41 Correct 2 ms 4340 KB Output is correct
42 Correct 2 ms 4444 KB Output is correct
43 Correct 2 ms 12892 KB Output is correct
44 Correct 3 ms 16732 KB Output is correct
45 Correct 2 ms 8540 KB Output is correct
46 Correct 2 ms 8540 KB Output is correct
47 Correct 1 ms 4416 KB Output is correct
48 Correct 2 ms 6492 KB Output is correct
49 Correct 2 ms 8540 KB Output is correct
50 Correct 2 ms 8540 KB Output is correct
51 Correct 2 ms 8536 KB Output is correct
52 Correct 2 ms 8540 KB Output is correct
53 Correct 2 ms 7516 KB Output is correct
54 Correct 2 ms 7516 KB Output is correct
55 Correct 2 ms 7556 KB Output is correct
56 Correct 2 ms 7516 KB Output is correct
57 Correct 2 ms 7516 KB Output is correct
58 Correct 2 ms 7516 KB Output is correct
59 Correct 3 ms 13148 KB Output is correct
60 Correct 4 ms 20828 KB Output is correct
61 Correct 3 ms 11100 KB Output is correct
62 Correct 3 ms 20828 KB Output is correct
63 Correct 3 ms 7516 KB Output is correct
64 Correct 3 ms 20828 KB Output is correct
65 Correct 3 ms 18780 KB Output is correct
66 Correct 2 ms 6492 KB Output is correct
67 Correct 3 ms 14684 KB Output is correct
68 Correct 2 ms 10588 KB Output is correct
69 Correct 3 ms 12636 KB Output is correct
70 Correct 4 ms 18780 KB Output is correct
71 Correct 4 ms 16988 KB Output is correct
72 Correct 3 ms 10588 KB Output is correct
73 Correct 2 ms 6492 KB Output is correct
74 Correct 3 ms 12800 KB Output is correct
75 Correct 4 ms 18780 KB Output is correct
76 Correct 11 ms 14196 KB Output is correct
77 Correct 10 ms 6008 KB Output is correct
78 Correct 12 ms 8368 KB Output is correct
79 Correct 4 ms 20828 KB Output is correct
80 Correct 4 ms 20840 KB Output is correct
81 Correct 4 ms 20828 KB Output is correct
82 Correct 5 ms 20828 KB Output is correct
83 Correct 4 ms 20828 KB Output is correct
84 Correct 4 ms 21080 KB Output is correct
85 Correct 4 ms 21084 KB Output is correct
86 Correct 4 ms 21084 KB Output is correct
87 Correct 6 ms 21236 KB Output is correct
88 Correct 5 ms 21052 KB Output is correct
89 Correct 5 ms 21064 KB Output is correct
90 Correct 15 ms 23192 KB Output is correct
91 Correct 15 ms 22968 KB Output is correct
92 Correct 15 ms 22856 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4188 KB Output is correct
2 Correct 1 ms 4188 KB Output is correct
3 Correct 1 ms 4188 KB Output is correct
4 Correct 1 ms 4188 KB Output is correct
5 Correct 1 ms 4188 KB Output is correct
6 Correct 1 ms 4188 KB Output is correct
7 Correct 1 ms 4328 KB Output is correct
8 Correct 1 ms 4188 KB Output is correct
9 Correct 1 ms 4184 KB Output is correct
10 Correct 1 ms 4188 KB Output is correct
11 Correct 1 ms 4188 KB Output is correct
12 Correct 1 ms 4188 KB Output is correct
13 Correct 1 ms 4444 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 2 ms 7516 KB Output is correct
16 Correct 2 ms 7516 KB Output is correct
17 Correct 3 ms 7496 KB Output is correct
18 Correct 2 ms 7516 KB Output is correct
19 Correct 2 ms 7516 KB Output is correct
20 Correct 2 ms 7516 KB Output is correct
21 Correct 3 ms 14940 KB Output is correct
22 Correct 3 ms 13148 KB Output is correct
23 Correct 3 ms 15020 KB Output is correct
24 Correct 11 ms 22192 KB Output is correct
25 Correct 11 ms 22108 KB Output is correct
26 Correct 11 ms 22108 KB Output is correct
27 Correct 3 ms 4956 KB Output is correct
28 Correct 3 ms 4772 KB Output is correct
29 Correct 3 ms 4956 KB Output is correct
30 Correct 3 ms 4956 KB Output is correct
31 Correct 3 ms 4956 KB Output is correct
32 Correct 3 ms 5112 KB Output is correct
33 Correct 121 ms 160592 KB Output is correct
34 Correct 167 ms 160596 KB Output is correct
35 Correct 167 ms 160596 KB Output is correct
36 Correct 178 ms 160732 KB Output is correct
37 Correct 160 ms 160676 KB Output is correct
38 Correct 174 ms 160596 KB Output is correct
39 Correct 181 ms 161876 KB Output is correct
40 Correct 180 ms 161620 KB Output is correct
41 Correct 183 ms 161620 KB Output is correct
42 Correct 2 ms 4188 KB Output is correct
43 Correct 1 ms 4188 KB Output is correct
44 Correct 1 ms 4188 KB Output is correct
45 Correct 1 ms 4188 KB Output is correct
46 Correct 2 ms 6492 KB Output is correct
47 Correct 1 ms 6492 KB Output is correct
48 Correct 2 ms 6492 KB Output is correct
49 Correct 1 ms 4420 KB Output is correct
50 Correct 2 ms 8540 KB Output is correct
51 Correct 2 ms 7260 KB Output is correct
52 Correct 2 ms 5212 KB Output is correct
53 Correct 2 ms 7004 KB Output is correct
54 Correct 2 ms 7004 KB Output is correct
55 Correct 2 ms 7260 KB Output is correct
56 Correct 2 ms 4340 KB Output is correct
57 Correct 2 ms 4444 KB Output is correct
58 Correct 2 ms 12892 KB Output is correct
59 Correct 3 ms 16732 KB Output is correct
60 Correct 2 ms 8540 KB Output is correct
61 Correct 2 ms 8540 KB Output is correct
62 Correct 1 ms 4416 KB Output is correct
63 Correct 2 ms 6492 KB Output is correct
64 Correct 2 ms 8540 KB Output is correct
65 Correct 2 ms 8540 KB Output is correct
66 Correct 2 ms 8536 KB Output is correct
67 Correct 2 ms 8540 KB Output is correct
68 Correct 2 ms 7516 KB Output is correct
69 Correct 2 ms 7516 KB Output is correct
70 Correct 2 ms 7556 KB Output is correct
71 Correct 2 ms 7516 KB Output is correct
72 Correct 2 ms 7516 KB Output is correct
73 Correct 2 ms 7516 KB Output is correct
74 Correct 3 ms 13148 KB Output is correct
75 Correct 4 ms 20828 KB Output is correct
76 Correct 3 ms 11100 KB Output is correct
77 Correct 3 ms 20828 KB Output is correct
78 Correct 3 ms 7516 KB Output is correct
79 Correct 3 ms 20828 KB Output is correct
80 Correct 3 ms 18780 KB Output is correct
81 Correct 2 ms 6492 KB Output is correct
82 Correct 3 ms 14684 KB Output is correct
83 Correct 2 ms 10588 KB Output is correct
84 Correct 3 ms 12636 KB Output is correct
85 Correct 4 ms 18780 KB Output is correct
86 Correct 4 ms 16988 KB Output is correct
87 Correct 3 ms 10588 KB Output is correct
88 Correct 2 ms 6492 KB Output is correct
89 Correct 3 ms 12800 KB Output is correct
90 Correct 4 ms 18780 KB Output is correct
91 Correct 11 ms 14196 KB Output is correct
92 Correct 10 ms 6008 KB Output is correct
93 Correct 12 ms 8368 KB Output is correct
94 Correct 4 ms 20828 KB Output is correct
95 Correct 4 ms 20840 KB Output is correct
96 Correct 4 ms 20828 KB Output is correct
97 Correct 5 ms 20828 KB Output is correct
98 Correct 4 ms 20828 KB Output is correct
99 Correct 4 ms 21080 KB Output is correct
100 Correct 4 ms 21084 KB Output is correct
101 Correct 4 ms 21084 KB Output is correct
102 Correct 6 ms 21236 KB Output is correct
103 Correct 5 ms 21052 KB Output is correct
104 Correct 5 ms 21064 KB Output is correct
105 Correct 15 ms 23192 KB Output is correct
106 Correct 15 ms 22968 KB Output is correct
107 Correct 15 ms 22856 KB Output is correct
108 Correct 3 ms 4956 KB Output is correct
109 Correct 108 ms 54772 KB Output is correct
110 Correct 81 ms 56664 KB Output is correct
111 Correct 69 ms 58456 KB Output is correct
112 Correct 88 ms 62808 KB Output is correct
113 Correct 72 ms 79168 KB Output is correct
114 Correct 54 ms 80984 KB Output is correct
115 Correct 11 ms 12376 KB Output is correct
116 Correct 64 ms 64852 KB Output is correct
117 Correct 35 ms 57940 KB Output is correct
118 Correct 12 ms 12636 KB Output is correct
119 Correct 91 ms 117076 KB Output is correct
120 Correct 113 ms 160604 KB Output is correct
121 Correct 93 ms 159624 KB Output is correct
122 Correct 41 ms 52060 KB Output is correct
123 Correct 23 ms 50776 KB Output is correct
124 Correct 25 ms 20060 KB Output is correct
125 Correct 16 ms 18772 KB Output is correct
126 Correct 6 ms 8284 KB Output is correct
127 Correct 48 ms 47444 KB Output is correct
128 Correct 12 ms 16216 KB Output is correct
129 Correct 16 ms 20252 KB Output is correct
130 Correct 3 ms 4956 KB Output is correct
131 Correct 151 ms 55144 KB Output is correct
132 Correct 151 ms 69464 KB Output is correct
133 Correct 146 ms 77660 KB Output is correct
134 Correct 145 ms 83656 KB Output is correct
135 Correct 145 ms 89976 KB Output is correct
136 Correct 129 ms 161616 KB Output is correct
137 Correct 113 ms 161620 KB Output is correct
138 Correct 151 ms 161620 KB Output is correct
139 Correct 123 ms 161664 KB Output is correct
140 Correct 125 ms 161620 KB Output is correct
141 Correct 147 ms 161620 KB Output is correct
142 Correct 187 ms 162196 KB Output is correct
143 Correct 142 ms 160372 KB Output is correct
144 Correct 189 ms 162384 KB Output is correct
145 Correct 110 ms 160380 KB Output is correct
146 Correct 188 ms 162384 KB Output is correct
147 Correct 139 ms 160364 KB Output is correct
148 Correct 175 ms 160804 KB Output is correct
149 Correct 89 ms 84760 KB Output is correct
150 Correct 63 ms 58068 KB Output is correct
151 Correct 48 ms 45648 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4188 KB Output is correct
2 Correct 1 ms 4188 KB Output is correct
3 Correct 1 ms 4188 KB Output is correct
4 Correct 1 ms 4188 KB Output is correct
5 Correct 1 ms 4188 KB Output is correct
6 Correct 1 ms 4188 KB Output is correct
7 Correct 1 ms 4328 KB Output is correct
8 Correct 1 ms 4188 KB Output is correct
9 Correct 1 ms 4184 KB Output is correct
10 Correct 1 ms 4188 KB Output is correct
11 Correct 1 ms 4188 KB Output is correct
12 Correct 1 ms 4188 KB Output is correct
13 Correct 1 ms 4444 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 2 ms 7516 KB Output is correct
16 Correct 2 ms 7516 KB Output is correct
17 Correct 3 ms 7496 KB Output is correct
18 Correct 2 ms 7516 KB Output is correct
19 Correct 2 ms 7516 KB Output is correct
20 Correct 2 ms 7516 KB Output is correct
21 Correct 3 ms 14940 KB Output is correct
22 Correct 3 ms 13148 KB Output is correct
23 Correct 3 ms 15020 KB Output is correct
24 Correct 11 ms 22192 KB Output is correct
25 Correct 11 ms 22108 KB Output is correct
26 Correct 11 ms 22108 KB Output is correct
27 Correct 3 ms 4956 KB Output is correct
28 Correct 3 ms 4772 KB Output is correct
29 Correct 3 ms 4956 KB Output is correct
30 Correct 3 ms 4956 KB Output is correct
31 Correct 3 ms 4956 KB Output is correct
32 Correct 3 ms 5112 KB Output is correct
33 Correct 121 ms 160592 KB Output is correct
34 Correct 167 ms 160596 KB Output is correct
35 Correct 167 ms 160596 KB Output is correct
36 Correct 178 ms 160732 KB Output is correct
37 Correct 160 ms 160676 KB Output is correct
38 Correct 174 ms 160596 KB Output is correct
39 Correct 181 ms 161876 KB Output is correct
40 Correct 180 ms 161620 KB Output is correct
41 Correct 183 ms 161620 KB Output is correct
42 Correct 9 ms 6612 KB Output is correct
43 Correct 6 ms 5724 KB Output is correct
44 Correct 10 ms 6360 KB Output is correct
45 Correct 7 ms 5720 KB Output is correct
46 Correct 7 ms 5724 KB Output is correct
47 Correct 11 ms 6724 KB Output is correct
48 Runtime error 38 ms 27948 KB Execution killed with signal 11
49 Halted 0 ms 0 KB -