Submission #737603

# Submission time Handle Problem Language Result Execution time Memory
737603 2023-05-07T12:22:46 Z Abrar_Al_Samit Painting Walls (APIO20_paint) C++17
51 / 100
1500 ms 85932 KB
#include "paint.h"
#include <bits/stdc++.h>
using namespace std;



const int nax = 1e5 + 3;

vector<int>cand[nax], col_to_wall[nax];
bool good[nax];
int tag[nax];
int curtag = 1;
int vis[nax];
int to[nax];

int minimumInstructions(
    int N, int M, int K, vector<int> C,
    vector<int> A, vector<vector<int>> B) {

    
    for(int i=0; i<N; ++i) {
        col_to_wall[C[i]].push_back(i);
    }

    for(int i=0; i<M; ++i) {
        for(int j=0; j<A[i]; ++j) {
            for(int x : col_to_wall[B[i][j]]) {
                cand[x].push_back(i);
            }
        }
    }

    for(int i=0; i<N; ++i) {
        sort(cand[i].begin(), cand[i].end());
    }

    for(int i=0; i<=N-M; ++i) {
        for(int j : cand[i]) {

            bool yasss = true;
            for(int l=0; l<M; ++l) {
                yasss &= binary_search(cand[i+l].begin(), 
                    cand[i+l].end(), (j+l)%M);

                if(!yasss) break;
            }
            good[i] |= yasss;
            if(yasss) break;
        }
    }


    if(!good[0]) return -1;
    int last = 0, pending = -1;

    int ans = 1;
    for(int i=1; i<N; ++i) {
        if(good[i]) {
            pending = i;
        }
        if(last+M==i) {
            if(pending==-1) return -1;
            last = pending;
            pending = -1;
            ++ans;
        }
    }
    return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4948 KB Output is correct
2 Correct 3 ms 4948 KB Output is correct
3 Correct 3 ms 4948 KB Output is correct
4 Correct 3 ms 4948 KB Output is correct
5 Correct 3 ms 5008 KB Output is correct
6 Correct 3 ms 4948 KB Output is correct
7 Correct 3 ms 4948 KB Output is correct
8 Correct 3 ms 4948 KB Output is correct
9 Correct 12 ms 4948 KB Output is correct
10 Correct 4 ms 4948 KB Output is correct
11 Correct 4 ms 5012 KB Output is correct
12 Correct 3 ms 5008 KB Output is correct
13 Correct 4 ms 5076 KB Output is correct
14 Correct 4 ms 4948 KB Output is correct
15 Correct 5 ms 4948 KB Output is correct
16 Correct 4 ms 5012 KB Output is correct
17 Correct 4 ms 5012 KB Output is correct
18 Correct 4 ms 5012 KB Output is correct
19 Correct 4 ms 5016 KB Output is correct
20 Correct 3 ms 4948 KB Output is correct
21 Correct 3 ms 4948 KB Output is correct
22 Correct 13 ms 5988 KB Output is correct
23 Correct 12 ms 5972 KB Output is correct
24 Correct 12 ms 6036 KB Output is correct
25 Correct 6 ms 5844 KB Output is correct
26 Correct 6 ms 5892 KB Output is correct
27 Correct 7 ms 5844 KB Output is correct
28 Correct 9 ms 5916 KB Output is correct
29 Correct 6 ms 5972 KB Output is correct
30 Correct 6 ms 5844 KB Output is correct
31 Correct 192 ms 6944 KB Output is correct
32 Correct 189 ms 6928 KB Output is correct
33 Correct 190 ms 6944 KB Output is correct
34 Correct 183 ms 6948 KB Output is correct
35 Correct 177 ms 6936 KB Output is correct
36 Correct 187 ms 6884 KB Output is correct
37 Correct 23 ms 7536 KB Output is correct
38 Correct 19 ms 7536 KB Output is correct
39 Correct 19 ms 7512 KB Output is correct
40 Correct 15 ms 9164 KB Output is correct
41 Correct 11 ms 7632 KB Output is correct
42 Correct 34 ms 9416 KB Output is correct
43 Correct 13 ms 8020 KB Output is correct
44 Correct 12 ms 7764 KB Output is correct
45 Correct 19 ms 9684 KB Output is correct
46 Execution timed out 1561 ms 17052 KB Time limit exceeded
47 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4948 KB Output is correct
2 Correct 3 ms 4948 KB Output is correct
3 Correct 3 ms 4948 KB Output is correct
4 Correct 3 ms 4948 KB Output is correct
5 Correct 3 ms 5008 KB Output is correct
6 Correct 3 ms 4948 KB Output is correct
7 Correct 3 ms 4948 KB Output is correct
8 Correct 3 ms 4948 KB Output is correct
9 Correct 12 ms 4948 KB Output is correct
10 Correct 4 ms 4948 KB Output is correct
11 Correct 4 ms 5012 KB Output is correct
12 Correct 3 ms 5008 KB Output is correct
13 Correct 4 ms 5076 KB Output is correct
14 Correct 4 ms 4948 KB Output is correct
15 Correct 5 ms 4948 KB Output is correct
16 Correct 4 ms 5012 KB Output is correct
17 Correct 4 ms 5012 KB Output is correct
18 Correct 4 ms 5012 KB Output is correct
19 Correct 4 ms 5016 KB Output is correct
20 Correct 3 ms 4948 KB Output is correct
21 Correct 3 ms 4948 KB Output is correct
22 Correct 3 ms 4948 KB Output is correct
23 Correct 3 ms 4948 KB Output is correct
24 Correct 3 ms 4948 KB Output is correct
25 Correct 3 ms 4948 KB Output is correct
26 Correct 3 ms 4948 KB Output is correct
27 Correct 4 ms 4948 KB Output is correct
28 Correct 4 ms 5000 KB Output is correct
29 Correct 4 ms 5004 KB Output is correct
30 Correct 3 ms 4948 KB Output is correct
31 Correct 3 ms 5004 KB Output is correct
32 Correct 3 ms 5008 KB Output is correct
33 Correct 4 ms 4948 KB Output is correct
34 Correct 3 ms 5012 KB Output is correct
35 Correct 3 ms 5008 KB Output is correct
36 Correct 5 ms 5012 KB Output is correct
37 Correct 3 ms 4948 KB Output is correct
38 Correct 3 ms 5012 KB Output is correct
39 Correct 3 ms 4948 KB Output is correct
40 Correct 3 ms 5008 KB Output is correct
41 Correct 4 ms 5052 KB Output is correct
42 Correct 4 ms 4948 KB Output is correct
43 Correct 3 ms 4948 KB Output is correct
44 Correct 3 ms 4948 KB Output is correct
45 Correct 3 ms 5076 KB Output is correct
46 Correct 3 ms 5076 KB Output is correct
47 Correct 4 ms 5076 KB Output is correct
48 Correct 8 ms 5076 KB Output is correct
49 Correct 3 ms 5076 KB Output is correct
50 Correct 4 ms 5012 KB Output is correct
51 Correct 5 ms 5076 KB Output is correct
52 Correct 4 ms 4988 KB Output is correct
53 Correct 4 ms 5076 KB Output is correct
54 Correct 4 ms 5076 KB Output is correct
55 Correct 4 ms 5024 KB Output is correct
56 Correct 3 ms 4948 KB Output is correct
57 Correct 4 ms 5008 KB Output is correct
58 Correct 3 ms 4948 KB Output is correct
59 Correct 4 ms 5012 KB Output is correct
60 Correct 3 ms 4948 KB Output is correct
61 Correct 4 ms 5008 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4948 KB Output is correct
2 Correct 3 ms 4948 KB Output is correct
3 Correct 3 ms 4948 KB Output is correct
4 Correct 3 ms 4948 KB Output is correct
5 Correct 3 ms 4948 KB Output is correct
6 Correct 3 ms 4948 KB Output is correct
7 Correct 3 ms 5008 KB Output is correct
8 Correct 3 ms 4948 KB Output is correct
9 Correct 3 ms 4948 KB Output is correct
10 Correct 3 ms 4948 KB Output is correct
11 Correct 12 ms 4948 KB Output is correct
12 Correct 4 ms 4948 KB Output is correct
13 Correct 4 ms 5012 KB Output is correct
14 Correct 3 ms 5008 KB Output is correct
15 Correct 4 ms 5076 KB Output is correct
16 Correct 4 ms 4948 KB Output is correct
17 Correct 5 ms 4948 KB Output is correct
18 Correct 4 ms 5012 KB Output is correct
19 Correct 4 ms 5012 KB Output is correct
20 Correct 4 ms 5012 KB Output is correct
21 Correct 4 ms 5016 KB Output is correct
22 Correct 3 ms 4948 KB Output is correct
23 Correct 3 ms 4948 KB Output is correct
24 Correct 13 ms 5988 KB Output is correct
25 Correct 12 ms 5972 KB Output is correct
26 Correct 12 ms 6036 KB Output is correct
27 Correct 3 ms 4948 KB Output is correct
28 Correct 3 ms 4948 KB Output is correct
29 Correct 3 ms 4948 KB Output is correct
30 Correct 4 ms 4948 KB Output is correct
31 Correct 4 ms 5000 KB Output is correct
32 Correct 4 ms 5004 KB Output is correct
33 Correct 3 ms 4948 KB Output is correct
34 Correct 3 ms 5004 KB Output is correct
35 Correct 3 ms 5008 KB Output is correct
36 Correct 4 ms 4948 KB Output is correct
37 Correct 3 ms 5012 KB Output is correct
38 Correct 3 ms 5008 KB Output is correct
39 Correct 5 ms 5012 KB Output is correct
40 Correct 3 ms 4948 KB Output is correct
41 Correct 3 ms 5012 KB Output is correct
42 Correct 3 ms 4948 KB Output is correct
43 Correct 3 ms 5008 KB Output is correct
44 Correct 4 ms 5052 KB Output is correct
45 Correct 4 ms 4948 KB Output is correct
46 Correct 3 ms 4948 KB Output is correct
47 Correct 3 ms 4948 KB Output is correct
48 Correct 3 ms 5076 KB Output is correct
49 Correct 3 ms 5076 KB Output is correct
50 Correct 4 ms 5076 KB Output is correct
51 Correct 8 ms 5076 KB Output is correct
52 Correct 3 ms 5076 KB Output is correct
53 Correct 4 ms 5012 KB Output is correct
54 Correct 5 ms 5076 KB Output is correct
55 Correct 4 ms 4988 KB Output is correct
56 Correct 4 ms 5076 KB Output is correct
57 Correct 4 ms 5076 KB Output is correct
58 Correct 4 ms 5024 KB Output is correct
59 Correct 3 ms 4948 KB Output is correct
60 Correct 4 ms 5008 KB Output is correct
61 Correct 3 ms 4948 KB Output is correct
62 Correct 4 ms 5012 KB Output is correct
63 Correct 3 ms 4948 KB Output is correct
64 Correct 4 ms 5008 KB Output is correct
65 Correct 4 ms 5204 KB Output is correct
66 Correct 4 ms 5132 KB Output is correct
67 Correct 4 ms 5224 KB Output is correct
68 Correct 9 ms 5204 KB Output is correct
69 Correct 5 ms 5204 KB Output is correct
70 Correct 7 ms 5212 KB Output is correct
71 Correct 6 ms 5204 KB Output is correct
72 Correct 5 ms 5204 KB Output is correct
73 Correct 4 ms 5076 KB Output is correct
74 Correct 5 ms 5148 KB Output is correct
75 Correct 5 ms 5204 KB Output is correct
76 Correct 13 ms 6056 KB Output is correct
77 Correct 19 ms 6248 KB Output is correct
78 Correct 16 ms 6348 KB Output is correct
79 Correct 7 ms 5460 KB Output is correct
80 Correct 6 ms 5520 KB Output is correct
81 Correct 7 ms 5564 KB Output is correct
82 Correct 7 ms 5460 KB Output is correct
83 Correct 6 ms 5460 KB Output is correct
84 Correct 17 ms 5272 KB Output is correct
85 Correct 8 ms 5280 KB Output is correct
86 Correct 7 ms 5332 KB Output is correct
87 Correct 6 ms 5332 KB Output is correct
88 Correct 6 ms 5352 KB Output is correct
89 Correct 6 ms 5232 KB Output is correct
90 Correct 36 ms 6476 KB Output is correct
91 Correct 18 ms 6392 KB Output is correct
92 Correct 17 ms 6476 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4948 KB Output is correct
2 Correct 3 ms 4948 KB Output is correct
3 Correct 3 ms 4948 KB Output is correct
4 Correct 3 ms 4948 KB Output is correct
5 Correct 3 ms 4948 KB Output is correct
6 Correct 3 ms 4948 KB Output is correct
7 Correct 3 ms 5008 KB Output is correct
8 Correct 3 ms 4948 KB Output is correct
9 Correct 3 ms 4948 KB Output is correct
10 Correct 3 ms 4948 KB Output is correct
11 Correct 12 ms 4948 KB Output is correct
12 Correct 4 ms 4948 KB Output is correct
13 Correct 4 ms 5012 KB Output is correct
14 Correct 3 ms 5008 KB Output is correct
15 Correct 4 ms 5076 KB Output is correct
16 Correct 4 ms 4948 KB Output is correct
17 Correct 5 ms 4948 KB Output is correct
18 Correct 4 ms 5012 KB Output is correct
19 Correct 4 ms 5012 KB Output is correct
20 Correct 4 ms 5012 KB Output is correct
21 Correct 4 ms 5016 KB Output is correct
22 Correct 3 ms 4948 KB Output is correct
23 Correct 3 ms 4948 KB Output is correct
24 Correct 13 ms 5988 KB Output is correct
25 Correct 12 ms 5972 KB Output is correct
26 Correct 12 ms 6036 KB Output is correct
27 Correct 6 ms 5844 KB Output is correct
28 Correct 6 ms 5892 KB Output is correct
29 Correct 7 ms 5844 KB Output is correct
30 Correct 9 ms 5916 KB Output is correct
31 Correct 6 ms 5972 KB Output is correct
32 Correct 6 ms 5844 KB Output is correct
33 Correct 192 ms 6944 KB Output is correct
34 Correct 189 ms 6928 KB Output is correct
35 Correct 190 ms 6944 KB Output is correct
36 Correct 183 ms 6948 KB Output is correct
37 Correct 177 ms 6936 KB Output is correct
38 Correct 187 ms 6884 KB Output is correct
39 Correct 23 ms 7536 KB Output is correct
40 Correct 19 ms 7536 KB Output is correct
41 Correct 19 ms 7512 KB Output is correct
42 Correct 3 ms 4948 KB Output is correct
43 Correct 3 ms 4948 KB Output is correct
44 Correct 3 ms 4948 KB Output is correct
45 Correct 4 ms 4948 KB Output is correct
46 Correct 4 ms 5000 KB Output is correct
47 Correct 4 ms 5004 KB Output is correct
48 Correct 3 ms 4948 KB Output is correct
49 Correct 3 ms 5004 KB Output is correct
50 Correct 3 ms 5008 KB Output is correct
51 Correct 4 ms 4948 KB Output is correct
52 Correct 3 ms 5012 KB Output is correct
53 Correct 3 ms 5008 KB Output is correct
54 Correct 5 ms 5012 KB Output is correct
55 Correct 3 ms 4948 KB Output is correct
56 Correct 3 ms 5012 KB Output is correct
57 Correct 3 ms 4948 KB Output is correct
58 Correct 3 ms 5008 KB Output is correct
59 Correct 4 ms 5052 KB Output is correct
60 Correct 4 ms 4948 KB Output is correct
61 Correct 3 ms 4948 KB Output is correct
62 Correct 3 ms 4948 KB Output is correct
63 Correct 3 ms 5076 KB Output is correct
64 Correct 3 ms 5076 KB Output is correct
65 Correct 4 ms 5076 KB Output is correct
66 Correct 8 ms 5076 KB Output is correct
67 Correct 3 ms 5076 KB Output is correct
68 Correct 4 ms 5012 KB Output is correct
69 Correct 5 ms 5076 KB Output is correct
70 Correct 4 ms 4988 KB Output is correct
71 Correct 4 ms 5076 KB Output is correct
72 Correct 4 ms 5076 KB Output is correct
73 Correct 4 ms 5024 KB Output is correct
74 Correct 3 ms 4948 KB Output is correct
75 Correct 4 ms 5008 KB Output is correct
76 Correct 3 ms 4948 KB Output is correct
77 Correct 4 ms 5012 KB Output is correct
78 Correct 3 ms 4948 KB Output is correct
79 Correct 4 ms 5008 KB Output is correct
80 Correct 4 ms 5204 KB Output is correct
81 Correct 4 ms 5132 KB Output is correct
82 Correct 4 ms 5224 KB Output is correct
83 Correct 9 ms 5204 KB Output is correct
84 Correct 5 ms 5204 KB Output is correct
85 Correct 7 ms 5212 KB Output is correct
86 Correct 6 ms 5204 KB Output is correct
87 Correct 5 ms 5204 KB Output is correct
88 Correct 4 ms 5076 KB Output is correct
89 Correct 5 ms 5148 KB Output is correct
90 Correct 5 ms 5204 KB Output is correct
91 Correct 13 ms 6056 KB Output is correct
92 Correct 19 ms 6248 KB Output is correct
93 Correct 16 ms 6348 KB Output is correct
94 Correct 7 ms 5460 KB Output is correct
95 Correct 6 ms 5520 KB Output is correct
96 Correct 7 ms 5564 KB Output is correct
97 Correct 7 ms 5460 KB Output is correct
98 Correct 6 ms 5460 KB Output is correct
99 Correct 17 ms 5272 KB Output is correct
100 Correct 8 ms 5280 KB Output is correct
101 Correct 7 ms 5332 KB Output is correct
102 Correct 6 ms 5332 KB Output is correct
103 Correct 6 ms 5352 KB Output is correct
104 Correct 6 ms 5232 KB Output is correct
105 Correct 36 ms 6476 KB Output is correct
106 Correct 18 ms 6392 KB Output is correct
107 Correct 17 ms 6476 KB Output is correct
108 Correct 6 ms 5912 KB Output is correct
109 Correct 355 ms 63788 KB Output is correct
110 Correct 681 ms 30168 KB Output is correct
111 Correct 446 ms 28600 KB Output is correct
112 Correct 454 ms 36480 KB Output is correct
113 Correct 262 ms 20556 KB Output is correct
114 Correct 127 ms 6988 KB Output is correct
115 Correct 28 ms 6868 KB Output is correct
116 Correct 122 ms 7436 KB Output is correct
117 Correct 91 ms 6872 KB Output is correct
118 Correct 29 ms 7048 KB Output is correct
119 Correct 162 ms 6800 KB Output is correct
120 Correct 39 ms 7112 KB Output is correct
121 Correct 152 ms 6044 KB Output is correct
122 Correct 19 ms 7372 KB Output is correct
123 Correct 41 ms 5928 KB Output is correct
124 Correct 22 ms 7896 KB Output is correct
125 Correct 27 ms 6428 KB Output is correct
126 Correct 13 ms 6452 KB Output is correct
127 Correct 69 ms 6844 KB Output is correct
128 Correct 20 ms 6228 KB Output is correct
129 Correct 19 ms 6356 KB Output is correct
130 Correct 7 ms 5912 KB Output is correct
131 Correct 501 ms 85932 KB Output is correct
132 Correct 1056 ms 45916 KB Output is correct
133 Correct 818 ms 45912 KB Output is correct
134 Correct 730 ms 45948 KB Output is correct
135 Correct 607 ms 41944 KB Output is correct
136 Correct 364 ms 7804 KB Output is correct
137 Correct 299 ms 7868 KB Output is correct
138 Correct 389 ms 7888 KB Output is correct
139 Correct 338 ms 7792 KB Output is correct
140 Correct 302 ms 7920 KB Output is correct
141 Correct 388 ms 7908 KB Output is correct
142 Correct 28 ms 8604 KB Output is correct
143 Correct 314 ms 6708 KB Output is correct
144 Correct 32 ms 8536 KB Output is correct
145 Correct 296 ms 6764 KB Output is correct
146 Correct 37 ms 8524 KB Output is correct
147 Correct 268 ms 6692 KB Output is correct
148 Correct 153 ms 7124 KB Output is correct
149 Correct 113 ms 7032 KB Output is correct
150 Correct 60 ms 6988 KB Output is correct
151 Correct 48 ms 6952 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4948 KB Output is correct
2 Correct 3 ms 4948 KB Output is correct
3 Correct 3 ms 4948 KB Output is correct
4 Correct 3 ms 4948 KB Output is correct
5 Correct 3 ms 4948 KB Output is correct
6 Correct 3 ms 4948 KB Output is correct
7 Correct 3 ms 5008 KB Output is correct
8 Correct 3 ms 4948 KB Output is correct
9 Correct 3 ms 4948 KB Output is correct
10 Correct 3 ms 4948 KB Output is correct
11 Correct 12 ms 4948 KB Output is correct
12 Correct 4 ms 4948 KB Output is correct
13 Correct 4 ms 5012 KB Output is correct
14 Correct 3 ms 5008 KB Output is correct
15 Correct 4 ms 5076 KB Output is correct
16 Correct 4 ms 4948 KB Output is correct
17 Correct 5 ms 4948 KB Output is correct
18 Correct 4 ms 5012 KB Output is correct
19 Correct 4 ms 5012 KB Output is correct
20 Correct 4 ms 5012 KB Output is correct
21 Correct 4 ms 5016 KB Output is correct
22 Correct 3 ms 4948 KB Output is correct
23 Correct 3 ms 4948 KB Output is correct
24 Correct 13 ms 5988 KB Output is correct
25 Correct 12 ms 5972 KB Output is correct
26 Correct 12 ms 6036 KB Output is correct
27 Correct 6 ms 5844 KB Output is correct
28 Correct 6 ms 5892 KB Output is correct
29 Correct 7 ms 5844 KB Output is correct
30 Correct 9 ms 5916 KB Output is correct
31 Correct 6 ms 5972 KB Output is correct
32 Correct 6 ms 5844 KB Output is correct
33 Correct 192 ms 6944 KB Output is correct
34 Correct 189 ms 6928 KB Output is correct
35 Correct 190 ms 6944 KB Output is correct
36 Correct 183 ms 6948 KB Output is correct
37 Correct 177 ms 6936 KB Output is correct
38 Correct 187 ms 6884 KB Output is correct
39 Correct 23 ms 7536 KB Output is correct
40 Correct 19 ms 7536 KB Output is correct
41 Correct 19 ms 7512 KB Output is correct
42 Correct 15 ms 9164 KB Output is correct
43 Correct 11 ms 7632 KB Output is correct
44 Correct 34 ms 9416 KB Output is correct
45 Correct 13 ms 8020 KB Output is correct
46 Correct 12 ms 7764 KB Output is correct
47 Correct 19 ms 9684 KB Output is correct
48 Execution timed out 1561 ms 17052 KB Time limit exceeded
49 Halted 0 ms 0 KB -