Submission #676580

# Submission time Handle Problem Language Result Execution time Memory
676580 2022-12-31T10:51:53 Z fatemetmhr Painting Walls (APIO20_paint) C++17
51 / 100
435 ms 165092 KB
// ~~ Be name khoda ~~

#include "paint.h"
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define all(x) x.begin(), x.end()
#define pb     push_back
#define fi     first
#define se     second

const int maxn5 = 1e5 + 10;
const int maxn  = 2e4 + 10;
const int maxm  = 2e3 + 10;

int have[maxn][maxm];
vector <int> out;
bool mark[maxn5];

int minimumInstructions(int N, int M, int K, vector<int> C, vector<int> A, vector<vector<int>> B){
    int n = N, m = M;
    for(int i = 0; i < m; i++){
        memset(mark, false, sizeof mark);
        for(auto u : B[i])
            mark[u] = true;
        for(int j = 0; j < n; j++)
            have[j][i] = mark[C[j]];
    }
    if(m == 1){
        bool re = true;
        for(int i = 0; i < n; i++)
            re &= have[i][0];
        return (re ? n : -1);
    }
    out.pb(-1);
    for(int i = 1; i < n; i++){
        bool good = false;
        for(int j = 0; j < m; j++) if(have[i][j]){
            have[i][j] = have[i - 1][j == 0 ? m - 1 : j - 1] + 1;
            good |= (have[i][j] >= m);
        }
        if(good){
            while(out.size() > 1 && i - out[out.size() - 2] <= m)
                out.pop_back();
            if(i - out.back() > m)
                return -1;
            out.pb(i);
        }
        //cout << i << ' ' << good << ' ' << out.size() << endl;
    }
    if(out.back() != n - 1)
        return -1;
    return out.size() - 1;
}

// hen?
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 308 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 2388 KB Output is correct
8 Correct 1 ms 2388 KB Output is correct
9 Correct 1 ms 2388 KB Output is correct
10 Correct 2 ms 2388 KB Output is correct
11 Correct 1 ms 2388 KB Output is correct
12 Correct 1 ms 2388 KB Output is correct
13 Correct 2 ms 2752 KB Output is correct
14 Correct 2 ms 2772 KB Output is correct
15 Correct 2 ms 2744 KB Output is correct
16 Correct 2 ms 2772 KB Output is correct
17 Correct 2 ms 2772 KB Output is correct
18 Correct 2 ms 2772 KB Output is correct
19 Correct 2 ms 2772 KB Output is correct
20 Correct 2 ms 2772 KB Output is correct
21 Correct 3 ms 2772 KB Output is correct
22 Correct 13 ms 4088 KB Output is correct
23 Correct 11 ms 4048 KB Output is correct
24 Correct 10 ms 4088 KB Output is correct
25 Correct 28 ms 80792 KB Output is correct
26 Correct 29 ms 80756 KB Output is correct
27 Correct 29 ms 80836 KB Output is correct
28 Correct 29 ms 80924 KB Output is correct
29 Correct 30 ms 80984 KB Output is correct
30 Correct 29 ms 81100 KB Output is correct
31 Correct 435 ms 158332 KB Output is correct
32 Correct 390 ms 158404 KB Output is correct
33 Correct 400 ms 158284 KB Output is correct
34 Correct 417 ms 158300 KB Output is correct
35 Correct 410 ms 158488 KB Output is correct
36 Correct 402 ms 158284 KB Output is correct
37 Correct 429 ms 159512 KB Output is correct
38 Correct 405 ms 159504 KB Output is correct
39 Correct 402 ms 159456 KB Output is correct
40 Runtime error 243 ms 165092 KB Execution killed with signal 11
41 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 308 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 2388 KB Output is correct
8 Correct 1 ms 2388 KB Output is correct
9 Correct 1 ms 2388 KB Output is correct
10 Correct 2 ms 2388 KB Output is correct
11 Correct 1 ms 2388 KB Output is correct
12 Correct 1 ms 2388 KB Output is correct
13 Correct 2 ms 2752 KB Output is correct
14 Correct 2 ms 2772 KB Output is correct
15 Correct 2 ms 2744 KB Output is correct
16 Correct 2 ms 2772 KB Output is correct
17 Correct 2 ms 2772 KB Output is correct
18 Correct 2 ms 2772 KB Output is correct
19 Correct 2 ms 2772 KB Output is correct
20 Correct 2 ms 2772 KB Output is correct
21 Correct 3 ms 2772 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 316 KB Output is correct
24 Correct 0 ms 316 KB Output is correct
25 Correct 0 ms 304 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 1460 KB Output is correct
28 Correct 1 ms 1748 KB Output is correct
29 Correct 1 ms 1364 KB Output is correct
30 Correct 1 ms 1748 KB Output is correct
31 Correct 2 ms 2132 KB Output is correct
32 Correct 2 ms 1896 KB Output is correct
33 Correct 2 ms 2248 KB Output is correct
34 Correct 2 ms 2388 KB Output is correct
35 Correct 2 ms 1724 KB Output is correct
36 Correct 2 ms 2132 KB Output is correct
37 Correct 2 ms 1976 KB Output is correct
38 Correct 1 ms 1620 KB Output is correct
39 Correct 1 ms 1620 KB Output is correct
40 Correct 2 ms 1888 KB Output is correct
41 Correct 1 ms 1876 KB Output is correct
42 Correct 2 ms 2260 KB Output is correct
43 Correct 1 ms 1748 KB Output is correct
44 Correct 1 ms 2356 KB Output is correct
45 Correct 1 ms 2388 KB Output is correct
46 Correct 2 ms 2388 KB Output is correct
47 Correct 1 ms 2484 KB Output is correct
48 Correct 2 ms 2516 KB Output is correct
49 Correct 2 ms 2516 KB Output is correct
50 Correct 2 ms 2772 KB Output is correct
51 Correct 2 ms 2772 KB Output is correct
52 Correct 2 ms 2772 KB Output is correct
53 Correct 2 ms 2772 KB Output is correct
54 Correct 3 ms 2752 KB Output is correct
55 Correct 3 ms 2772 KB Output is correct
56 Correct 3 ms 2772 KB Output is correct
57 Correct 3 ms 2772 KB Output is correct
58 Correct 2 ms 2756 KB Output is correct
59 Correct 2 ms 2772 KB Output is correct
60 Correct 2 ms 2772 KB Output is correct
61 Correct 3 ms 2772 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 316 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 308 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 2388 KB Output is correct
10 Correct 1 ms 2388 KB Output is correct
11 Correct 1 ms 2388 KB Output is correct
12 Correct 2 ms 2388 KB Output is correct
13 Correct 1 ms 2388 KB Output is correct
14 Correct 1 ms 2388 KB Output is correct
15 Correct 2 ms 2752 KB Output is correct
16 Correct 2 ms 2772 KB Output is correct
17 Correct 2 ms 2744 KB Output is correct
18 Correct 2 ms 2772 KB Output is correct
19 Correct 2 ms 2772 KB Output is correct
20 Correct 2 ms 2772 KB Output is correct
21 Correct 2 ms 2772 KB Output is correct
22 Correct 2 ms 2772 KB Output is correct
23 Correct 3 ms 2772 KB Output is correct
24 Correct 13 ms 4088 KB Output is correct
25 Correct 11 ms 4048 KB Output is correct
26 Correct 10 ms 4088 KB Output is correct
27 Correct 0 ms 316 KB Output is correct
28 Correct 0 ms 304 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 1460 KB Output is correct
31 Correct 1 ms 1748 KB Output is correct
32 Correct 1 ms 1364 KB Output is correct
33 Correct 1 ms 1748 KB Output is correct
34 Correct 2 ms 2132 KB Output is correct
35 Correct 2 ms 1896 KB Output is correct
36 Correct 2 ms 2248 KB Output is correct
37 Correct 2 ms 2388 KB Output is correct
38 Correct 2 ms 1724 KB Output is correct
39 Correct 2 ms 2132 KB Output is correct
40 Correct 2 ms 1976 KB Output is correct
41 Correct 1 ms 1620 KB Output is correct
42 Correct 1 ms 1620 KB Output is correct
43 Correct 2 ms 1888 KB Output is correct
44 Correct 1 ms 1876 KB Output is correct
45 Correct 2 ms 2260 KB Output is correct
46 Correct 1 ms 1748 KB Output is correct
47 Correct 1 ms 2356 KB Output is correct
48 Correct 1 ms 2388 KB Output is correct
49 Correct 2 ms 2388 KB Output is correct
50 Correct 1 ms 2484 KB Output is correct
51 Correct 2 ms 2516 KB Output is correct
52 Correct 2 ms 2516 KB Output is correct
53 Correct 2 ms 2772 KB Output is correct
54 Correct 2 ms 2772 KB Output is correct
55 Correct 2 ms 2772 KB Output is correct
56 Correct 2 ms 2772 KB Output is correct
57 Correct 3 ms 2752 KB Output is correct
58 Correct 3 ms 2772 KB Output is correct
59 Correct 3 ms 2772 KB Output is correct
60 Correct 3 ms 2772 KB Output is correct
61 Correct 2 ms 2756 KB Output is correct
62 Correct 2 ms 2772 KB Output is correct
63 Correct 2 ms 2772 KB Output is correct
64 Correct 3 ms 2772 KB Output is correct
65 Correct 2 ms 1492 KB Output is correct
66 Correct 1 ms 2388 KB Output is correct
67 Correct 2 ms 2516 KB Output is correct
68 Correct 2 ms 2480 KB Output is correct
69 Correct 2 ms 2388 KB Output is correct
70 Correct 3 ms 2516 KB Output is correct
71 Correct 3 ms 2444 KB Output is correct
72 Correct 3 ms 2248 KB Output is correct
73 Correct 2 ms 1988 KB Output is correct
74 Correct 3 ms 2004 KB Output is correct
75 Correct 3 ms 2096 KB Output is correct
76 Correct 13 ms 3108 KB Output is correct
77 Correct 12 ms 3436 KB Output is correct
78 Correct 14 ms 3768 KB Output is correct
79 Correct 3 ms 2772 KB Output is correct
80 Correct 2 ms 2744 KB Output is correct
81 Correct 2 ms 2744 KB Output is correct
82 Correct 2 ms 2772 KB Output is correct
83 Correct 2 ms 2772 KB Output is correct
84 Correct 4 ms 2900 KB Output is correct
85 Correct 5 ms 2900 KB Output is correct
86 Correct 4 ms 2884 KB Output is correct
87 Correct 4 ms 2900 KB Output is correct
88 Correct 3 ms 2968 KB Output is correct
89 Correct 6 ms 2852 KB Output is correct
90 Correct 18 ms 4884 KB Output is correct
91 Correct 15 ms 4896 KB Output is correct
92 Correct 15 ms 4844 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 316 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 308 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 2388 KB Output is correct
10 Correct 1 ms 2388 KB Output is correct
11 Correct 1 ms 2388 KB Output is correct
12 Correct 2 ms 2388 KB Output is correct
13 Correct 1 ms 2388 KB Output is correct
14 Correct 1 ms 2388 KB Output is correct
15 Correct 2 ms 2752 KB Output is correct
16 Correct 2 ms 2772 KB Output is correct
17 Correct 2 ms 2744 KB Output is correct
18 Correct 2 ms 2772 KB Output is correct
19 Correct 2 ms 2772 KB Output is correct
20 Correct 2 ms 2772 KB Output is correct
21 Correct 2 ms 2772 KB Output is correct
22 Correct 2 ms 2772 KB Output is correct
23 Correct 3 ms 2772 KB Output is correct
24 Correct 13 ms 4088 KB Output is correct
25 Correct 11 ms 4048 KB Output is correct
26 Correct 10 ms 4088 KB Output is correct
27 Correct 28 ms 80792 KB Output is correct
28 Correct 29 ms 80756 KB Output is correct
29 Correct 29 ms 80836 KB Output is correct
30 Correct 29 ms 80924 KB Output is correct
31 Correct 30 ms 80984 KB Output is correct
32 Correct 29 ms 81100 KB Output is correct
33 Correct 435 ms 158332 KB Output is correct
34 Correct 390 ms 158404 KB Output is correct
35 Correct 400 ms 158284 KB Output is correct
36 Correct 417 ms 158300 KB Output is correct
37 Correct 410 ms 158488 KB Output is correct
38 Correct 402 ms 158284 KB Output is correct
39 Correct 429 ms 159512 KB Output is correct
40 Correct 405 ms 159504 KB Output is correct
41 Correct 402 ms 159456 KB Output is correct
42 Correct 0 ms 316 KB Output is correct
43 Correct 0 ms 304 KB Output is correct
44 Correct 1 ms 340 KB Output is correct
45 Correct 1 ms 1460 KB Output is correct
46 Correct 1 ms 1748 KB Output is correct
47 Correct 1 ms 1364 KB Output is correct
48 Correct 1 ms 1748 KB Output is correct
49 Correct 2 ms 2132 KB Output is correct
50 Correct 2 ms 1896 KB Output is correct
51 Correct 2 ms 2248 KB Output is correct
52 Correct 2 ms 2388 KB Output is correct
53 Correct 2 ms 1724 KB Output is correct
54 Correct 2 ms 2132 KB Output is correct
55 Correct 2 ms 1976 KB Output is correct
56 Correct 1 ms 1620 KB Output is correct
57 Correct 1 ms 1620 KB Output is correct
58 Correct 2 ms 1888 KB Output is correct
59 Correct 1 ms 1876 KB Output is correct
60 Correct 2 ms 2260 KB Output is correct
61 Correct 1 ms 1748 KB Output is correct
62 Correct 1 ms 2356 KB Output is correct
63 Correct 1 ms 2388 KB Output is correct
64 Correct 2 ms 2388 KB Output is correct
65 Correct 1 ms 2484 KB Output is correct
66 Correct 2 ms 2516 KB Output is correct
67 Correct 2 ms 2516 KB Output is correct
68 Correct 2 ms 2772 KB Output is correct
69 Correct 2 ms 2772 KB Output is correct
70 Correct 2 ms 2772 KB Output is correct
71 Correct 2 ms 2772 KB Output is correct
72 Correct 3 ms 2752 KB Output is correct
73 Correct 3 ms 2772 KB Output is correct
74 Correct 3 ms 2772 KB Output is correct
75 Correct 3 ms 2772 KB Output is correct
76 Correct 2 ms 2756 KB Output is correct
77 Correct 2 ms 2772 KB Output is correct
78 Correct 2 ms 2772 KB Output is correct
79 Correct 3 ms 2772 KB Output is correct
80 Correct 2 ms 1492 KB Output is correct
81 Correct 1 ms 2388 KB Output is correct
82 Correct 2 ms 2516 KB Output is correct
83 Correct 2 ms 2480 KB Output is correct
84 Correct 2 ms 2388 KB Output is correct
85 Correct 3 ms 2516 KB Output is correct
86 Correct 3 ms 2444 KB Output is correct
87 Correct 3 ms 2248 KB Output is correct
88 Correct 2 ms 1988 KB Output is correct
89 Correct 3 ms 2004 KB Output is correct
90 Correct 3 ms 2096 KB Output is correct
91 Correct 13 ms 3108 KB Output is correct
92 Correct 12 ms 3436 KB Output is correct
93 Correct 14 ms 3768 KB Output is correct
94 Correct 3 ms 2772 KB Output is correct
95 Correct 2 ms 2744 KB Output is correct
96 Correct 2 ms 2744 KB Output is correct
97 Correct 2 ms 2772 KB Output is correct
98 Correct 2 ms 2772 KB Output is correct
99 Correct 4 ms 2900 KB Output is correct
100 Correct 5 ms 2900 KB Output is correct
101 Correct 4 ms 2884 KB Output is correct
102 Correct 4 ms 2900 KB Output is correct
103 Correct 3 ms 2968 KB Output is correct
104 Correct 6 ms 2852 KB Output is correct
105 Correct 18 ms 4884 KB Output is correct
106 Correct 15 ms 4896 KB Output is correct
107 Correct 15 ms 4844 KB Output is correct
108 Correct 32 ms 80460 KB Output is correct
109 Correct 120 ms 93740 KB Output is correct
110 Correct 112 ms 80648 KB Output is correct
111 Correct 109 ms 77244 KB Output is correct
112 Correct 153 ms 106088 KB Output is correct
113 Correct 139 ms 83820 KB Output is correct
114 Correct 142 ms 88316 KB Output is correct
115 Correct 35 ms 44272 KB Output is correct
116 Correct 170 ms 126156 KB Output is correct
117 Correct 102 ms 74128 KB Output is correct
118 Correct 40 ms 56364 KB Output is correct
119 Correct 244 ms 113868 KB Output is correct
120 Correct 251 ms 94896 KB Output is correct
121 Correct 237 ms 93924 KB Output is correct
122 Correct 115 ms 73292 KB Output is correct
123 Correct 104 ms 72016 KB Output is correct
124 Correct 73 ms 88520 KB Output is correct
125 Correct 62 ms 87116 KB Output is correct
126 Correct 29 ms 64084 KB Output is correct
127 Correct 134 ms 113980 KB Output is correct
128 Correct 48 ms 62000 KB Output is correct
129 Correct 55 ms 67484 KB Output is correct
130 Correct 31 ms 80972 KB Output is correct
131 Correct 181 ms 130128 KB Output is correct
132 Correct 198 ms 143424 KB Output is correct
133 Correct 239 ms 151564 KB Output is correct
134 Correct 300 ms 157996 KB Output is correct
135 Correct 278 ms 157940 KB Output is correct
136 Correct 393 ms 159252 KB Output is correct
137 Correct 393 ms 159236 KB Output is correct
138 Correct 396 ms 159192 KB Output is correct
139 Correct 386 ms 159224 KB Output is correct
140 Correct 395 ms 159292 KB Output is correct
141 Correct 393 ms 159232 KB Output is correct
142 Correct 386 ms 160376 KB Output is correct
143 Correct 416 ms 158316 KB Output is correct
144 Correct 415 ms 160312 KB Output is correct
145 Correct 429 ms 158468 KB Output is correct
146 Correct 419 ms 160280 KB Output is correct
147 Correct 396 ms 158288 KB Output is correct
148 Correct 400 ms 158704 KB Output is correct
149 Correct 239 ms 158416 KB Output is correct
150 Correct 169 ms 133248 KB Output is correct
151 Correct 135 ms 120276 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 316 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 308 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 2388 KB Output is correct
10 Correct 1 ms 2388 KB Output is correct
11 Correct 1 ms 2388 KB Output is correct
12 Correct 2 ms 2388 KB Output is correct
13 Correct 1 ms 2388 KB Output is correct
14 Correct 1 ms 2388 KB Output is correct
15 Correct 2 ms 2752 KB Output is correct
16 Correct 2 ms 2772 KB Output is correct
17 Correct 2 ms 2744 KB Output is correct
18 Correct 2 ms 2772 KB Output is correct
19 Correct 2 ms 2772 KB Output is correct
20 Correct 2 ms 2772 KB Output is correct
21 Correct 2 ms 2772 KB Output is correct
22 Correct 2 ms 2772 KB Output is correct
23 Correct 3 ms 2772 KB Output is correct
24 Correct 13 ms 4088 KB Output is correct
25 Correct 11 ms 4048 KB Output is correct
26 Correct 10 ms 4088 KB Output is correct
27 Correct 28 ms 80792 KB Output is correct
28 Correct 29 ms 80756 KB Output is correct
29 Correct 29 ms 80836 KB Output is correct
30 Correct 29 ms 80924 KB Output is correct
31 Correct 30 ms 80984 KB Output is correct
32 Correct 29 ms 81100 KB Output is correct
33 Correct 435 ms 158332 KB Output is correct
34 Correct 390 ms 158404 KB Output is correct
35 Correct 400 ms 158284 KB Output is correct
36 Correct 417 ms 158300 KB Output is correct
37 Correct 410 ms 158488 KB Output is correct
38 Correct 402 ms 158284 KB Output is correct
39 Correct 429 ms 159512 KB Output is correct
40 Correct 405 ms 159504 KB Output is correct
41 Correct 402 ms 159456 KB Output is correct
42 Runtime error 243 ms 165092 KB Execution killed with signal 11
43 Halted 0 ms 0 KB -