Submission #1054453

# Submission time Handle Problem Language Result Execution time Memory
1054453 2024-08-12T10:01:06 Z alexander707070 Painting Walls (APIO20_paint) C++14
51 / 100
666 ms 94800 KB
#include<bits/stdc++.h>
#include "paint.h"

#define MAXN 100007
using namespace std;

int n,m,k,ans;
int c[MAXN];
unordered_set<int> cols[MAXN];

bool can[20007][2007];
int to[2][2007];
int best[MAXN],pref[MAXN];

int minimumInstructions(int N, int M, int K, vector<int> C,vector<int> A, vector< vector<int> > B) {
    n=N; m=M; k=K;

    for(int i=1;i<=n;i++){
        c[i]=C[i-1];
    }

    for(int i=1;i<=m;i++){
        for(int s:B[i-1])cols[i].insert(s);
    }

    for(int i=1;i<=n;i++){
        for(int f=1;f<=m;f++){
            if(cols[f].find(c[i])!=cols[f].end())can[i][f]=true;
        }
    }

    for(int i=n;i>=1;i--){
        for(int f=1;f<=m;f++){
            if(!can[i][f])to[i%2][f]=0;
            else{
                if(f<m)to[i%2][f]=to[1-i%2][f+1]+1;
                else to[i%2][f]=to[1-i%2][1]+1;
            }

            if(to[i%2][f]>=m)best[i]=max(best[i],i+m);
        }
    }

    for(int i=1;i<=n;i++){
        pref[i]=max(pref[i-1],best[i]);
    }

    int pos=1;
    while(pos<=n){
        if(pref[pos]<=pos)return -1;

        pos=pref[pos];
        ans++;
    }

    return ans;
}

/*
int main(){
    //cout<<minimumInstructions(8, 3, 5, {3, 3, 1, 3, 4, 4, 2, 2}, {3, 2, 2}, {{0, 1, 2}, {2, 3}, {3, 4}});
    cout<<minimumInstructions(5, 4, 4, {1, 0, 1, 2, 2}, {2, 1, 1, 1}, {{0, 1}, {1}, {2}, {3}});


    return 0;
}
*/
# Verdict Execution time Memory Grader output
1 Correct 2 ms 8792 KB Output is correct
2 Correct 1 ms 8796 KB Output is correct
3 Correct 1 ms 8796 KB Output is correct
4 Correct 1 ms 8796 KB Output is correct
5 Correct 1 ms 8792 KB Output is correct
6 Correct 1 ms 8796 KB Output is correct
7 Correct 1 ms 8796 KB Output is correct
8 Correct 1 ms 8796 KB Output is correct
9 Correct 1 ms 8888 KB Output is correct
10 Correct 2 ms 8792 KB Output is correct
11 Correct 2 ms 8792 KB Output is correct
12 Correct 1 ms 8796 KB Output is correct
13 Correct 2 ms 8796 KB Output is correct
14 Correct 2 ms 8796 KB Output is correct
15 Correct 2 ms 8900 KB Output is correct
16 Correct 2 ms 8796 KB Output is correct
17 Correct 2 ms 8796 KB Output is correct
18 Correct 2 ms 8968 KB Output is correct
19 Correct 2 ms 8796 KB Output is correct
20 Correct 2 ms 8888 KB Output is correct
21 Correct 2 ms 8796 KB Output is correct
22 Correct 14 ms 13728 KB Output is correct
23 Correct 14 ms 13656 KB Output is correct
24 Correct 14 ms 13660 KB Output is correct
25 Correct 5 ms 46060 KB Output is correct
26 Correct 5 ms 45916 KB Output is correct
27 Correct 6 ms 45916 KB Output is correct
28 Correct 7 ms 45916 KB Output is correct
29 Correct 6 ms 45916 KB Output is correct
30 Correct 5 ms 45916 KB Output is correct
31 Correct 407 ms 47388 KB Output is correct
32 Correct 388 ms 47184 KB Output is correct
33 Correct 404 ms 47136 KB Output is correct
34 Correct 412 ms 47132 KB Output is correct
35 Correct 401 ms 47172 KB Output is correct
36 Correct 379 ms 47120 KB Output is correct
37 Correct 642 ms 51088 KB Output is correct
38 Correct 666 ms 51796 KB Output is correct
39 Correct 654 ms 51844 KB Output is correct
40 Runtime error 34 ms 94800 KB Execution killed with signal 11
41 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 8792 KB Output is correct
2 Correct 1 ms 8796 KB Output is correct
3 Correct 1 ms 8796 KB Output is correct
4 Correct 1 ms 8796 KB Output is correct
5 Correct 1 ms 8792 KB Output is correct
6 Correct 1 ms 8796 KB Output is correct
7 Correct 1 ms 8796 KB Output is correct
8 Correct 1 ms 8796 KB Output is correct
9 Correct 1 ms 8888 KB Output is correct
10 Correct 2 ms 8792 KB Output is correct
11 Correct 2 ms 8792 KB Output is correct
12 Correct 1 ms 8796 KB Output is correct
13 Correct 2 ms 8796 KB Output is correct
14 Correct 2 ms 8796 KB Output is correct
15 Correct 2 ms 8900 KB Output is correct
16 Correct 2 ms 8796 KB Output is correct
17 Correct 2 ms 8796 KB Output is correct
18 Correct 2 ms 8968 KB Output is correct
19 Correct 2 ms 8796 KB Output is correct
20 Correct 2 ms 8888 KB Output is correct
21 Correct 2 ms 8796 KB Output is correct
22 Correct 1 ms 8792 KB Output is correct
23 Correct 1 ms 8796 KB Output is correct
24 Correct 1 ms 8792 KB Output is correct
25 Correct 1 ms 8796 KB Output is correct
26 Correct 1 ms 8796 KB Output is correct
27 Correct 1 ms 8796 KB Output is correct
28 Correct 1 ms 8796 KB Output is correct
29 Correct 2 ms 8920 KB Output is correct
30 Correct 1 ms 8796 KB Output is correct
31 Correct 1 ms 8796 KB Output is correct
32 Correct 1 ms 8796 KB Output is correct
33 Correct 2 ms 8796 KB Output is correct
34 Correct 2 ms 8796 KB Output is correct
35 Correct 1 ms 8796 KB Output is correct
36 Correct 2 ms 8796 KB Output is correct
37 Correct 1 ms 8796 KB Output is correct
38 Correct 1 ms 8796 KB Output is correct
39 Correct 1 ms 8796 KB Output is correct
40 Correct 2 ms 8796 KB Output is correct
41 Correct 1 ms 8796 KB Output is correct
42 Correct 1 ms 8796 KB Output is correct
43 Correct 1 ms 8796 KB Output is correct
44 Correct 1 ms 8796 KB Output is correct
45 Correct 2 ms 8796 KB Output is correct
46 Correct 2 ms 8928 KB Output is correct
47 Correct 1 ms 8796 KB Output is correct
48 Correct 1 ms 8796 KB Output is correct
49 Correct 1 ms 8796 KB Output is correct
50 Correct 2 ms 8796 KB Output is correct
51 Correct 2 ms 8796 KB Output is correct
52 Correct 2 ms 8796 KB Output is correct
53 Correct 1 ms 8808 KB Output is correct
54 Correct 2 ms 8796 KB Output is correct
55 Correct 1 ms 8796 KB Output is correct
56 Correct 2 ms 8796 KB Output is correct
57 Correct 2 ms 8796 KB Output is correct
58 Correct 2 ms 8796 KB Output is correct
59 Correct 2 ms 8792 KB Output is correct
60 Correct 2 ms 8796 KB Output is correct
61 Correct 2 ms 8796 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 8792 KB Output is correct
2 Correct 1 ms 8796 KB Output is correct
3 Correct 2 ms 8792 KB Output is correct
4 Correct 1 ms 8796 KB Output is correct
5 Correct 1 ms 8796 KB Output is correct
6 Correct 1 ms 8796 KB Output is correct
7 Correct 1 ms 8792 KB Output is correct
8 Correct 1 ms 8796 KB Output is correct
9 Correct 1 ms 8796 KB Output is correct
10 Correct 1 ms 8796 KB Output is correct
11 Correct 1 ms 8888 KB Output is correct
12 Correct 2 ms 8792 KB Output is correct
13 Correct 2 ms 8792 KB Output is correct
14 Correct 1 ms 8796 KB Output is correct
15 Correct 2 ms 8796 KB Output is correct
16 Correct 2 ms 8796 KB Output is correct
17 Correct 2 ms 8900 KB Output is correct
18 Correct 2 ms 8796 KB Output is correct
19 Correct 2 ms 8796 KB Output is correct
20 Correct 2 ms 8968 KB Output is correct
21 Correct 2 ms 8796 KB Output is correct
22 Correct 2 ms 8888 KB Output is correct
23 Correct 2 ms 8796 KB Output is correct
24 Correct 14 ms 13728 KB Output is correct
25 Correct 14 ms 13656 KB Output is correct
26 Correct 14 ms 13660 KB Output is correct
27 Correct 1 ms 8792 KB Output is correct
28 Correct 1 ms 8796 KB Output is correct
29 Correct 1 ms 8796 KB Output is correct
30 Correct 1 ms 8796 KB Output is correct
31 Correct 1 ms 8796 KB Output is correct
32 Correct 2 ms 8920 KB Output is correct
33 Correct 1 ms 8796 KB Output is correct
34 Correct 1 ms 8796 KB Output is correct
35 Correct 1 ms 8796 KB Output is correct
36 Correct 2 ms 8796 KB Output is correct
37 Correct 2 ms 8796 KB Output is correct
38 Correct 1 ms 8796 KB Output is correct
39 Correct 2 ms 8796 KB Output is correct
40 Correct 1 ms 8796 KB Output is correct
41 Correct 1 ms 8796 KB Output is correct
42 Correct 1 ms 8796 KB Output is correct
43 Correct 2 ms 8796 KB Output is correct
44 Correct 1 ms 8796 KB Output is correct
45 Correct 1 ms 8796 KB Output is correct
46 Correct 1 ms 8796 KB Output is correct
47 Correct 1 ms 8796 KB Output is correct
48 Correct 2 ms 8796 KB Output is correct
49 Correct 2 ms 8928 KB Output is correct
50 Correct 1 ms 8796 KB Output is correct
51 Correct 1 ms 8796 KB Output is correct
52 Correct 1 ms 8796 KB Output is correct
53 Correct 2 ms 8796 KB Output is correct
54 Correct 2 ms 8796 KB Output is correct
55 Correct 2 ms 8796 KB Output is correct
56 Correct 1 ms 8808 KB Output is correct
57 Correct 2 ms 8796 KB Output is correct
58 Correct 1 ms 8796 KB Output is correct
59 Correct 2 ms 8796 KB Output is correct
60 Correct 2 ms 8796 KB Output is correct
61 Correct 2 ms 8796 KB Output is correct
62 Correct 2 ms 8792 KB Output is correct
63 Correct 2 ms 8796 KB Output is correct
64 Correct 2 ms 8796 KB Output is correct
65 Correct 2 ms 8796 KB Output is correct
66 Correct 1 ms 8920 KB Output is correct
67 Correct 2 ms 8796 KB Output is correct
68 Correct 1 ms 8796 KB Output is correct
69 Correct 1 ms 8956 KB Output is correct
70 Correct 3 ms 9308 KB Output is correct
71 Correct 3 ms 9308 KB Output is correct
72 Correct 3 ms 9352 KB Output is correct
73 Correct 2 ms 9052 KB Output is correct
74 Correct 3 ms 9308 KB Output is correct
75 Correct 3 ms 9308 KB Output is correct
76 Correct 13 ms 14192 KB Output is correct
77 Correct 13 ms 14520 KB Output is correct
78 Correct 16 ms 15704 KB Output is correct
79 Correct 2 ms 8796 KB Output is correct
80 Correct 2 ms 8796 KB Output is correct
81 Correct 2 ms 8796 KB Output is correct
82 Correct 2 ms 8796 KB Output is correct
83 Correct 2 ms 8796 KB Output is correct
84 Correct 4 ms 9652 KB Output is correct
85 Correct 4 ms 9560 KB Output is correct
86 Correct 4 ms 9672 KB Output is correct
87 Correct 4 ms 9672 KB Output is correct
88 Correct 4 ms 9564 KB Output is correct
89 Correct 4 ms 9592 KB Output is correct
90 Correct 20 ms 16728 KB Output is correct
91 Correct 20 ms 16744 KB Output is correct
92 Correct 20 ms 16740 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 8792 KB Output is correct
2 Correct 1 ms 8796 KB Output is correct
3 Correct 2 ms 8792 KB Output is correct
4 Correct 1 ms 8796 KB Output is correct
5 Correct 1 ms 8796 KB Output is correct
6 Correct 1 ms 8796 KB Output is correct
7 Correct 1 ms 8792 KB Output is correct
8 Correct 1 ms 8796 KB Output is correct
9 Correct 1 ms 8796 KB Output is correct
10 Correct 1 ms 8796 KB Output is correct
11 Correct 1 ms 8888 KB Output is correct
12 Correct 2 ms 8792 KB Output is correct
13 Correct 2 ms 8792 KB Output is correct
14 Correct 1 ms 8796 KB Output is correct
15 Correct 2 ms 8796 KB Output is correct
16 Correct 2 ms 8796 KB Output is correct
17 Correct 2 ms 8900 KB Output is correct
18 Correct 2 ms 8796 KB Output is correct
19 Correct 2 ms 8796 KB Output is correct
20 Correct 2 ms 8968 KB Output is correct
21 Correct 2 ms 8796 KB Output is correct
22 Correct 2 ms 8888 KB Output is correct
23 Correct 2 ms 8796 KB Output is correct
24 Correct 14 ms 13728 KB Output is correct
25 Correct 14 ms 13656 KB Output is correct
26 Correct 14 ms 13660 KB Output is correct
27 Correct 5 ms 46060 KB Output is correct
28 Correct 5 ms 45916 KB Output is correct
29 Correct 6 ms 45916 KB Output is correct
30 Correct 7 ms 45916 KB Output is correct
31 Correct 6 ms 45916 KB Output is correct
32 Correct 5 ms 45916 KB Output is correct
33 Correct 407 ms 47388 KB Output is correct
34 Correct 388 ms 47184 KB Output is correct
35 Correct 404 ms 47136 KB Output is correct
36 Correct 412 ms 47132 KB Output is correct
37 Correct 401 ms 47172 KB Output is correct
38 Correct 379 ms 47120 KB Output is correct
39 Correct 642 ms 51088 KB Output is correct
40 Correct 666 ms 51796 KB Output is correct
41 Correct 654 ms 51844 KB Output is correct
42 Correct 1 ms 8792 KB Output is correct
43 Correct 1 ms 8796 KB Output is correct
44 Correct 1 ms 8796 KB Output is correct
45 Correct 1 ms 8796 KB Output is correct
46 Correct 1 ms 8796 KB Output is correct
47 Correct 2 ms 8920 KB Output is correct
48 Correct 1 ms 8796 KB Output is correct
49 Correct 1 ms 8796 KB Output is correct
50 Correct 1 ms 8796 KB Output is correct
51 Correct 2 ms 8796 KB Output is correct
52 Correct 2 ms 8796 KB Output is correct
53 Correct 1 ms 8796 KB Output is correct
54 Correct 2 ms 8796 KB Output is correct
55 Correct 1 ms 8796 KB Output is correct
56 Correct 1 ms 8796 KB Output is correct
57 Correct 1 ms 8796 KB Output is correct
58 Correct 2 ms 8796 KB Output is correct
59 Correct 1 ms 8796 KB Output is correct
60 Correct 1 ms 8796 KB Output is correct
61 Correct 1 ms 8796 KB Output is correct
62 Correct 1 ms 8796 KB Output is correct
63 Correct 2 ms 8796 KB Output is correct
64 Correct 2 ms 8928 KB Output is correct
65 Correct 1 ms 8796 KB Output is correct
66 Correct 1 ms 8796 KB Output is correct
67 Correct 1 ms 8796 KB Output is correct
68 Correct 2 ms 8796 KB Output is correct
69 Correct 2 ms 8796 KB Output is correct
70 Correct 2 ms 8796 KB Output is correct
71 Correct 1 ms 8808 KB Output is correct
72 Correct 2 ms 8796 KB Output is correct
73 Correct 1 ms 8796 KB Output is correct
74 Correct 2 ms 8796 KB Output is correct
75 Correct 2 ms 8796 KB Output is correct
76 Correct 2 ms 8796 KB Output is correct
77 Correct 2 ms 8792 KB Output is correct
78 Correct 2 ms 8796 KB Output is correct
79 Correct 2 ms 8796 KB Output is correct
80 Correct 2 ms 8796 KB Output is correct
81 Correct 1 ms 8920 KB Output is correct
82 Correct 2 ms 8796 KB Output is correct
83 Correct 1 ms 8796 KB Output is correct
84 Correct 1 ms 8956 KB Output is correct
85 Correct 3 ms 9308 KB Output is correct
86 Correct 3 ms 9308 KB Output is correct
87 Correct 3 ms 9352 KB Output is correct
88 Correct 2 ms 9052 KB Output is correct
89 Correct 3 ms 9308 KB Output is correct
90 Correct 3 ms 9308 KB Output is correct
91 Correct 13 ms 14192 KB Output is correct
92 Correct 13 ms 14520 KB Output is correct
93 Correct 16 ms 15704 KB Output is correct
94 Correct 2 ms 8796 KB Output is correct
95 Correct 2 ms 8796 KB Output is correct
96 Correct 2 ms 8796 KB Output is correct
97 Correct 2 ms 8796 KB Output is correct
98 Correct 2 ms 8796 KB Output is correct
99 Correct 4 ms 9652 KB Output is correct
100 Correct 4 ms 9560 KB Output is correct
101 Correct 4 ms 9672 KB Output is correct
102 Correct 4 ms 9672 KB Output is correct
103 Correct 4 ms 9564 KB Output is correct
104 Correct 4 ms 9592 KB Output is correct
105 Correct 20 ms 16728 KB Output is correct
106 Correct 20 ms 16744 KB Output is correct
107 Correct 20 ms 16740 KB Output is correct
108 Correct 5 ms 46172 KB Output is correct
109 Correct 42 ms 37960 KB Output is correct
110 Correct 26 ms 33876 KB Output is correct
111 Correct 25 ms 31828 KB Output is correct
112 Correct 35 ms 40072 KB Output is correct
113 Correct 30 ms 29784 KB Output is correct
114 Correct 176 ms 32612 KB Output is correct
115 Correct 21 ms 30800 KB Output is correct
116 Correct 206 ms 48088 KB Output is correct
117 Correct 106 ms 32596 KB Output is correct
118 Correct 32 ms 37204 KB Output is correct
119 Correct 283 ms 40276 KB Output is correct
120 Correct 359 ms 37008 KB Output is correct
121 Correct 147 ms 32592 KB Output is correct
122 Correct 118 ms 38084 KB Output is correct
123 Correct 47 ms 32332 KB Output is correct
124 Correct 64 ms 53072 KB Output is correct
125 Correct 42 ms 47184 KB Output is correct
126 Correct 11 ms 41068 KB Output is correct
127 Correct 136 ms 47668 KB Output is correct
128 Correct 25 ms 36948 KB Output is correct
129 Correct 39 ms 36812 KB Output is correct
130 Correct 5 ms 46172 KB Output is correct
131 Correct 59 ms 46276 KB Output is correct
132 Correct 52 ms 46172 KB Output is correct
133 Correct 56 ms 46332 KB Output is correct
134 Correct 67 ms 46568 KB Output is correct
135 Correct 71 ms 46420 KB Output is correct
136 Correct 534 ms 50776 KB Output is correct
137 Correct 529 ms 50768 KB Output is correct
138 Correct 539 ms 50844 KB Output is correct
139 Correct 544 ms 50956 KB Output is correct
140 Correct 553 ms 50816 KB Output is correct
141 Correct 535 ms 50864 KB Output is correct
142 Correct 589 ms 55404 KB Output is correct
143 Correct 399 ms 47376 KB Output is correct
144 Correct 609 ms 55376 KB Output is correct
145 Correct 406 ms 47452 KB Output is correct
146 Correct 629 ms 55472 KB Output is correct
147 Correct 392 ms 47368 KB Output is correct
148 Correct 392 ms 48208 KB Output is correct
149 Correct 199 ms 48212 KB Output is correct
150 Correct 167 ms 47956 KB Output is correct
151 Correct 144 ms 47744 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 8792 KB Output is correct
2 Correct 1 ms 8796 KB Output is correct
3 Correct 2 ms 8792 KB Output is correct
4 Correct 1 ms 8796 KB Output is correct
5 Correct 1 ms 8796 KB Output is correct
6 Correct 1 ms 8796 KB Output is correct
7 Correct 1 ms 8792 KB Output is correct
8 Correct 1 ms 8796 KB Output is correct
9 Correct 1 ms 8796 KB Output is correct
10 Correct 1 ms 8796 KB Output is correct
11 Correct 1 ms 8888 KB Output is correct
12 Correct 2 ms 8792 KB Output is correct
13 Correct 2 ms 8792 KB Output is correct
14 Correct 1 ms 8796 KB Output is correct
15 Correct 2 ms 8796 KB Output is correct
16 Correct 2 ms 8796 KB Output is correct
17 Correct 2 ms 8900 KB Output is correct
18 Correct 2 ms 8796 KB Output is correct
19 Correct 2 ms 8796 KB Output is correct
20 Correct 2 ms 8968 KB Output is correct
21 Correct 2 ms 8796 KB Output is correct
22 Correct 2 ms 8888 KB Output is correct
23 Correct 2 ms 8796 KB Output is correct
24 Correct 14 ms 13728 KB Output is correct
25 Correct 14 ms 13656 KB Output is correct
26 Correct 14 ms 13660 KB Output is correct
27 Correct 5 ms 46060 KB Output is correct
28 Correct 5 ms 45916 KB Output is correct
29 Correct 6 ms 45916 KB Output is correct
30 Correct 7 ms 45916 KB Output is correct
31 Correct 6 ms 45916 KB Output is correct
32 Correct 5 ms 45916 KB Output is correct
33 Correct 407 ms 47388 KB Output is correct
34 Correct 388 ms 47184 KB Output is correct
35 Correct 404 ms 47136 KB Output is correct
36 Correct 412 ms 47132 KB Output is correct
37 Correct 401 ms 47172 KB Output is correct
38 Correct 379 ms 47120 KB Output is correct
39 Correct 642 ms 51088 KB Output is correct
40 Correct 666 ms 51796 KB Output is correct
41 Correct 654 ms 51844 KB Output is correct
42 Runtime error 34 ms 94800 KB Execution killed with signal 11
43 Halted 0 ms 0 KB -