Submission #319489

# Submission time Handle Problem Language Result Execution time Memory
319489 2020-11-05T11:49:13 Z VEGAnn Painting Walls (APIO20_paint) C++14
28 / 100
1500 ms 29284 KB
#include "paint.h"
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ft first
using namespace std;
using namespace __gnu_pbds;
const int M = 50100;
const int N = 100100;
const int K = 100100;
const int oo = 2e9;
gp_hash_table<int, bool> inside[K];
int f[N];

// проверить, вдруг на большие ограничения залетит

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 < m; i++)
    for (int j = 0; j < A[i]; j++)
        inside[B[i][j]][i] = 1;

    f[n] = 0;

    fill(f, f + n, oo);

    for (int i = n - m; i >= 0; i--){
        int mn = oo;

        for (int j = 1; j <= m; j++)
            mn = min(mn, f[i + j]);

        if (mn == oo) continue;

        for (auto cr : inside[C[i]]){
            int now = cr.ft;
            bool ok = 1;

            for (int it = 1; it < m && ok; it++){
                now++;

                if (now == m) now = 0;

                if (inside[C[i + it]].find(now) == inside[now].end()){
                    ok = 0;
                    break;
                }
            }

            if (ok){
                f[i] = mn + 1;
                break;
            }
        }
    }

    return (f[0] == oo ? -1 : f[0]);
}
# Verdict Execution time Memory Grader output
1 Correct 24 ms 21484 KB Output is correct
2 Correct 23 ms 21484 KB Output is correct
3 Correct 24 ms 21484 KB Output is correct
4 Correct 24 ms 21484 KB Output is correct
5 Correct 23 ms 21484 KB Output is correct
6 Correct 23 ms 21484 KB Output is correct
7 Correct 23 ms 21484 KB Output is correct
8 Correct 25 ms 21484 KB Output is correct
9 Correct 26 ms 21484 KB Output is correct
10 Correct 24 ms 21484 KB Output is correct
11 Correct 24 ms 21484 KB Output is correct
12 Correct 24 ms 21476 KB Output is correct
13 Correct 24 ms 21484 KB Output is correct
14 Correct 24 ms 21484 KB Output is correct
15 Correct 24 ms 21484 KB Output is correct
16 Correct 24 ms 21632 KB Output is correct
17 Correct 26 ms 21484 KB Output is correct
18 Correct 25 ms 21612 KB Output is correct
19 Correct 24 ms 21484 KB Output is correct
20 Correct 24 ms 21484 KB Output is correct
21 Correct 24 ms 21484 KB Output is correct
22 Correct 61 ms 22900 KB Output is correct
23 Correct 61 ms 22892 KB Output is correct
24 Correct 62 ms 23012 KB Output is correct
25 Correct 26 ms 21740 KB Output is correct
26 Correct 26 ms 21740 KB Output is correct
27 Correct 26 ms 21740 KB Output is correct
28 Correct 27 ms 21860 KB Output is correct
29 Correct 25 ms 21736 KB Output is correct
30 Correct 26 ms 21736 KB Output is correct
31 Correct 980 ms 22244 KB Output is correct
32 Correct 984 ms 22372 KB Output is correct
33 Correct 980 ms 22372 KB Output is correct
34 Correct 985 ms 22372 KB Output is correct
35 Correct 976 ms 22372 KB Output is correct
36 Correct 996 ms 22372 KB Output is correct
37 Correct 109 ms 23336 KB Output is correct
38 Correct 103 ms 23528 KB Output is correct
39 Correct 104 ms 23396 KB Output is correct
40 Correct 33 ms 22764 KB Output is correct
41 Correct 30 ms 22244 KB Output is correct
42 Correct 37 ms 22884 KB Output is correct
43 Correct 32 ms 22388 KB Output is correct
44 Correct 29 ms 22244 KB Output is correct
45 Correct 34 ms 22884 KB Output is correct
46 Execution timed out 1545 ms 29284 KB Time limit exceeded
47 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 24 ms 21484 KB Output is correct
2 Correct 24 ms 21612 KB Output is correct
3 Correct 24 ms 21484 KB Output is correct
4 Correct 23 ms 21484 KB Output is correct
5 Correct 24 ms 21484 KB Output is correct
6 Correct 24 ms 21484 KB Output is correct
7 Correct 23 ms 21484 KB Output is correct
8 Correct 23 ms 21484 KB Output is correct
9 Correct 23 ms 21484 KB Output is correct
10 Correct 25 ms 21484 KB Output is correct
11 Correct 26 ms 21484 KB Output is correct
12 Correct 24 ms 21484 KB Output is correct
13 Correct 24 ms 21484 KB Output is correct
14 Correct 24 ms 21476 KB Output is correct
15 Correct 24 ms 21484 KB Output is correct
16 Correct 24 ms 21484 KB Output is correct
17 Correct 24 ms 21484 KB Output is correct
18 Correct 24 ms 21632 KB Output is correct
19 Correct 26 ms 21484 KB Output is correct
20 Correct 25 ms 21612 KB Output is correct
21 Correct 24 ms 21484 KB Output is correct
22 Correct 24 ms 21484 KB Output is correct
23 Correct 24 ms 21484 KB Output is correct
24 Correct 24 ms 21484 KB Output is correct
25 Correct 25 ms 21484 KB Output is correct
26 Correct 24 ms 21484 KB Output is correct
27 Correct 26 ms 21612 KB Output is correct
28 Correct 24 ms 21484 KB Output is correct
29 Correct 26 ms 21632 KB Output is correct
30 Correct 23 ms 21484 KB Output is correct
31 Correct 24 ms 21484 KB Output is correct
32 Correct 24 ms 21484 KB Output is correct
33 Correct 29 ms 21484 KB Output is correct
34 Correct 28 ms 21484 KB Output is correct
35 Correct 27 ms 21484 KB Output is correct
36 Correct 32 ms 21484 KB Output is correct
37 Correct 24 ms 21504 KB Output is correct
38 Correct 24 ms 21484 KB Output is correct
39 Correct 24 ms 21484 KB Output is correct
40 Correct 25 ms 21484 KB Output is correct
41 Correct 26 ms 21484 KB Output is correct
42 Correct 24 ms 21484 KB Output is correct
43 Correct 24 ms 21484 KB Output is correct
44 Correct 25 ms 21484 KB Output is correct
45 Correct 24 ms 21484 KB Output is correct
46 Correct 24 ms 21484 KB Output is correct
47 Correct 24 ms 21480 KB Output is correct
48 Correct 24 ms 21484 KB Output is correct
49 Correct 24 ms 21484 KB Output is correct
50 Correct 25 ms 21484 KB Output is correct
51 Correct 25 ms 21484 KB Output is correct
52 Correct 24 ms 21484 KB Output is correct
53 Correct 26 ms 21604 KB Output is correct
54 Correct 24 ms 21612 KB Output is correct
55 Correct 24 ms 21564 KB Output is correct
56 Correct 24 ms 21484 KB Output is correct
57 Correct 24 ms 21484 KB Output is correct
58 Correct 24 ms 21612 KB Output is correct
59 Correct 24 ms 21484 KB Output is correct
60 Correct 24 ms 21484 KB Output is correct
61 Correct 26 ms 21484 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 24 ms 21484 KB Output is correct
2 Correct 24 ms 21612 KB Output is correct
3 Correct 24 ms 21484 KB Output is correct
4 Correct 23 ms 21484 KB Output is correct
5 Correct 24 ms 21484 KB Output is correct
6 Correct 24 ms 21484 KB Output is correct
7 Correct 23 ms 21484 KB Output is correct
8 Correct 23 ms 21484 KB Output is correct
9 Correct 23 ms 21484 KB Output is correct
10 Correct 25 ms 21484 KB Output is correct
11 Correct 26 ms 21484 KB Output is correct
12 Correct 24 ms 21484 KB Output is correct
13 Correct 24 ms 21484 KB Output is correct
14 Correct 24 ms 21476 KB Output is correct
15 Correct 24 ms 21484 KB Output is correct
16 Correct 24 ms 21484 KB Output is correct
17 Correct 24 ms 21484 KB Output is correct
18 Correct 24 ms 21632 KB Output is correct
19 Correct 26 ms 21484 KB Output is correct
20 Correct 25 ms 21612 KB Output is correct
21 Correct 24 ms 21484 KB Output is correct
22 Correct 24 ms 21484 KB Output is correct
23 Correct 24 ms 21484 KB Output is correct
24 Correct 61 ms 22900 KB Output is correct
25 Correct 61 ms 22892 KB Output is correct
26 Correct 62 ms 23012 KB Output is correct
27 Correct 24 ms 21484 KB Output is correct
28 Correct 25 ms 21484 KB Output is correct
29 Correct 24 ms 21484 KB Output is correct
30 Correct 26 ms 21612 KB Output is correct
31 Correct 24 ms 21484 KB Output is correct
32 Correct 26 ms 21632 KB Output is correct
33 Correct 23 ms 21484 KB Output is correct
34 Correct 24 ms 21484 KB Output is correct
35 Correct 24 ms 21484 KB Output is correct
36 Correct 29 ms 21484 KB Output is correct
37 Correct 28 ms 21484 KB Output is correct
38 Correct 27 ms 21484 KB Output is correct
39 Correct 32 ms 21484 KB Output is correct
40 Correct 24 ms 21504 KB Output is correct
41 Correct 24 ms 21484 KB Output is correct
42 Correct 24 ms 21484 KB Output is correct
43 Correct 25 ms 21484 KB Output is correct
44 Correct 26 ms 21484 KB Output is correct
45 Correct 24 ms 21484 KB Output is correct
46 Correct 24 ms 21484 KB Output is correct
47 Correct 25 ms 21484 KB Output is correct
48 Correct 24 ms 21484 KB Output is correct
49 Correct 24 ms 21484 KB Output is correct
50 Correct 24 ms 21480 KB Output is correct
51 Correct 24 ms 21484 KB Output is correct
52 Correct 24 ms 21484 KB Output is correct
53 Correct 25 ms 21484 KB Output is correct
54 Correct 25 ms 21484 KB Output is correct
55 Correct 24 ms 21484 KB Output is correct
56 Correct 26 ms 21604 KB Output is correct
57 Correct 24 ms 21612 KB Output is correct
58 Correct 24 ms 21564 KB Output is correct
59 Correct 24 ms 21484 KB Output is correct
60 Correct 24 ms 21484 KB Output is correct
61 Correct 24 ms 21612 KB Output is correct
62 Correct 24 ms 21484 KB Output is correct
63 Correct 24 ms 21484 KB Output is correct
64 Correct 26 ms 21484 KB Output is correct
65 Correct 25 ms 21484 KB Output is correct
66 Correct 25 ms 21516 KB Output is correct
67 Correct 26 ms 21484 KB Output is correct
68 Correct 25 ms 21484 KB Output is correct
69 Correct 25 ms 21484 KB Output is correct
70 Correct 28 ms 21996 KB Output is correct
71 Correct 29 ms 21996 KB Output is correct
72 Correct 27 ms 22116 KB Output is correct
73 Correct 27 ms 22116 KB Output is correct
74 Correct 29 ms 22252 KB Output is correct
75 Correct 29 ms 21860 KB Output is correct
76 Correct 67 ms 24036 KB Output is correct
77 Correct 48 ms 23268 KB Output is correct
78 Correct 75 ms 24676 KB Output is correct
79 Correct 25 ms 21484 KB Output is correct
80 Correct 25 ms 21612 KB Output is correct
81 Correct 25 ms 21484 KB Output is correct
82 Correct 26 ms 21612 KB Output is correct
83 Correct 25 ms 21612 KB Output is correct
84 Correct 29 ms 22252 KB Output is correct
85 Correct 30 ms 22116 KB Output is correct
86 Correct 30 ms 22124 KB Output is correct
87 Correct 30 ms 22116 KB Output is correct
88 Correct 30 ms 22156 KB Output is correct
89 Correct 30 ms 22252 KB Output is correct
90 Correct 79 ms 24420 KB Output is correct
91 Correct 83 ms 24164 KB Output is correct
92 Correct 79 ms 24164 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 24 ms 21484 KB Output is correct
2 Correct 24 ms 21612 KB Output is correct
3 Correct 24 ms 21484 KB Output is correct
4 Correct 23 ms 21484 KB Output is correct
5 Correct 24 ms 21484 KB Output is correct
6 Correct 24 ms 21484 KB Output is correct
7 Correct 23 ms 21484 KB Output is correct
8 Correct 23 ms 21484 KB Output is correct
9 Correct 23 ms 21484 KB Output is correct
10 Correct 25 ms 21484 KB Output is correct
11 Correct 26 ms 21484 KB Output is correct
12 Correct 24 ms 21484 KB Output is correct
13 Correct 24 ms 21484 KB Output is correct
14 Correct 24 ms 21476 KB Output is correct
15 Correct 24 ms 21484 KB Output is correct
16 Correct 24 ms 21484 KB Output is correct
17 Correct 24 ms 21484 KB Output is correct
18 Correct 24 ms 21632 KB Output is correct
19 Correct 26 ms 21484 KB Output is correct
20 Correct 25 ms 21612 KB Output is correct
21 Correct 24 ms 21484 KB Output is correct
22 Correct 24 ms 21484 KB Output is correct
23 Correct 24 ms 21484 KB Output is correct
24 Correct 61 ms 22900 KB Output is correct
25 Correct 61 ms 22892 KB Output is correct
26 Correct 62 ms 23012 KB Output is correct
27 Correct 26 ms 21740 KB Output is correct
28 Correct 26 ms 21740 KB Output is correct
29 Correct 26 ms 21740 KB Output is correct
30 Correct 27 ms 21860 KB Output is correct
31 Correct 25 ms 21736 KB Output is correct
32 Correct 26 ms 21736 KB Output is correct
33 Correct 980 ms 22244 KB Output is correct
34 Correct 984 ms 22372 KB Output is correct
35 Correct 980 ms 22372 KB Output is correct
36 Correct 985 ms 22372 KB Output is correct
37 Correct 976 ms 22372 KB Output is correct
38 Correct 996 ms 22372 KB Output is correct
39 Correct 109 ms 23336 KB Output is correct
40 Correct 103 ms 23528 KB Output is correct
41 Correct 104 ms 23396 KB Output is correct
42 Correct 24 ms 21484 KB Output is correct
43 Correct 25 ms 21484 KB Output is correct
44 Correct 24 ms 21484 KB Output is correct
45 Correct 26 ms 21612 KB Output is correct
46 Correct 24 ms 21484 KB Output is correct
47 Correct 26 ms 21632 KB Output is correct
48 Correct 23 ms 21484 KB Output is correct
49 Correct 24 ms 21484 KB Output is correct
50 Correct 24 ms 21484 KB Output is correct
51 Correct 29 ms 21484 KB Output is correct
52 Correct 28 ms 21484 KB Output is correct
53 Correct 27 ms 21484 KB Output is correct
54 Correct 32 ms 21484 KB Output is correct
55 Correct 24 ms 21504 KB Output is correct
56 Correct 24 ms 21484 KB Output is correct
57 Correct 24 ms 21484 KB Output is correct
58 Correct 25 ms 21484 KB Output is correct
59 Correct 26 ms 21484 KB Output is correct
60 Correct 24 ms 21484 KB Output is correct
61 Correct 24 ms 21484 KB Output is correct
62 Correct 25 ms 21484 KB Output is correct
63 Correct 24 ms 21484 KB Output is correct
64 Correct 24 ms 21484 KB Output is correct
65 Correct 24 ms 21480 KB Output is correct
66 Correct 24 ms 21484 KB Output is correct
67 Correct 24 ms 21484 KB Output is correct
68 Correct 25 ms 21484 KB Output is correct
69 Correct 25 ms 21484 KB Output is correct
70 Correct 24 ms 21484 KB Output is correct
71 Correct 26 ms 21604 KB Output is correct
72 Correct 24 ms 21612 KB Output is correct
73 Correct 24 ms 21564 KB Output is correct
74 Correct 24 ms 21484 KB Output is correct
75 Correct 24 ms 21484 KB Output is correct
76 Correct 24 ms 21612 KB Output is correct
77 Correct 24 ms 21484 KB Output is correct
78 Correct 24 ms 21484 KB Output is correct
79 Correct 26 ms 21484 KB Output is correct
80 Correct 25 ms 21484 KB Output is correct
81 Correct 25 ms 21516 KB Output is correct
82 Correct 26 ms 21484 KB Output is correct
83 Correct 25 ms 21484 KB Output is correct
84 Correct 25 ms 21484 KB Output is correct
85 Correct 28 ms 21996 KB Output is correct
86 Correct 29 ms 21996 KB Output is correct
87 Correct 27 ms 22116 KB Output is correct
88 Correct 27 ms 22116 KB Output is correct
89 Correct 29 ms 22252 KB Output is correct
90 Correct 29 ms 21860 KB Output is correct
91 Correct 67 ms 24036 KB Output is correct
92 Correct 48 ms 23268 KB Output is correct
93 Correct 75 ms 24676 KB Output is correct
94 Correct 25 ms 21484 KB Output is correct
95 Correct 25 ms 21612 KB Output is correct
96 Correct 25 ms 21484 KB Output is correct
97 Correct 26 ms 21612 KB Output is correct
98 Correct 25 ms 21612 KB Output is correct
99 Correct 29 ms 22252 KB Output is correct
100 Correct 30 ms 22116 KB Output is correct
101 Correct 30 ms 22124 KB Output is correct
102 Correct 30 ms 22116 KB Output is correct
103 Correct 30 ms 22156 KB Output is correct
104 Correct 30 ms 22252 KB Output is correct
105 Correct 79 ms 24420 KB Output is correct
106 Correct 83 ms 24164 KB Output is correct
107 Correct 79 ms 24164 KB Output is correct
108 Correct 26 ms 21740 KB Output is correct
109 Correct 65 ms 21740 KB Output is correct
110 Correct 35 ms 21728 KB Output is correct
111 Correct 35 ms 21740 KB Output is correct
112 Correct 39 ms 21860 KB Output is correct
113 Correct 37 ms 21984 KB Output is correct
114 Correct 384 ms 24676 KB Output is correct
115 Correct 63 ms 24292 KB Output is correct
116 Correct 343 ms 26084 KB Output is correct
117 Correct 205 ms 24440 KB Output is correct
118 Correct 71 ms 24804 KB Output is correct
119 Correct 767 ms 22500 KB Output is correct
120 Correct 79 ms 23752 KB Output is correct
121 Correct 243 ms 21996 KB Output is correct
122 Correct 73 ms 24952 KB Output is correct
123 Correct 83 ms 21860 KB Output is correct
124 Correct 73 ms 24680 KB Output is correct
125 Correct 58 ms 22116 KB Output is correct
126 Correct 38 ms 21988 KB Output is correct
127 Correct 107 ms 22252 KB Output is correct
128 Correct 45 ms 21984 KB Output is correct
129 Correct 54 ms 22116 KB Output is correct
130 Correct 26 ms 21740 KB Output is correct
131 Correct 83 ms 21868 KB Output is correct
132 Correct 45 ms 21868 KB Output is correct
133 Correct 47 ms 21868 KB Output is correct
134 Correct 50 ms 21996 KB Output is correct
135 Correct 51 ms 22116 KB Output is correct
136 Execution timed out 1544 ms 26468 KB Time limit exceeded
137 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 24 ms 21484 KB Output is correct
2 Correct 24 ms 21612 KB Output is correct
3 Correct 24 ms 21484 KB Output is correct
4 Correct 23 ms 21484 KB Output is correct
5 Correct 24 ms 21484 KB Output is correct
6 Correct 24 ms 21484 KB Output is correct
7 Correct 23 ms 21484 KB Output is correct
8 Correct 23 ms 21484 KB Output is correct
9 Correct 23 ms 21484 KB Output is correct
10 Correct 25 ms 21484 KB Output is correct
11 Correct 26 ms 21484 KB Output is correct
12 Correct 24 ms 21484 KB Output is correct
13 Correct 24 ms 21484 KB Output is correct
14 Correct 24 ms 21476 KB Output is correct
15 Correct 24 ms 21484 KB Output is correct
16 Correct 24 ms 21484 KB Output is correct
17 Correct 24 ms 21484 KB Output is correct
18 Correct 24 ms 21632 KB Output is correct
19 Correct 26 ms 21484 KB Output is correct
20 Correct 25 ms 21612 KB Output is correct
21 Correct 24 ms 21484 KB Output is correct
22 Correct 24 ms 21484 KB Output is correct
23 Correct 24 ms 21484 KB Output is correct
24 Correct 61 ms 22900 KB Output is correct
25 Correct 61 ms 22892 KB Output is correct
26 Correct 62 ms 23012 KB Output is correct
27 Correct 26 ms 21740 KB Output is correct
28 Correct 26 ms 21740 KB Output is correct
29 Correct 26 ms 21740 KB Output is correct
30 Correct 27 ms 21860 KB Output is correct
31 Correct 25 ms 21736 KB Output is correct
32 Correct 26 ms 21736 KB Output is correct
33 Correct 980 ms 22244 KB Output is correct
34 Correct 984 ms 22372 KB Output is correct
35 Correct 980 ms 22372 KB Output is correct
36 Correct 985 ms 22372 KB Output is correct
37 Correct 976 ms 22372 KB Output is correct
38 Correct 996 ms 22372 KB Output is correct
39 Correct 109 ms 23336 KB Output is correct
40 Correct 103 ms 23528 KB Output is correct
41 Correct 104 ms 23396 KB Output is correct
42 Correct 33 ms 22764 KB Output is correct
43 Correct 30 ms 22244 KB Output is correct
44 Correct 37 ms 22884 KB Output is correct
45 Correct 32 ms 22388 KB Output is correct
46 Correct 29 ms 22244 KB Output is correct
47 Correct 34 ms 22884 KB Output is correct
48 Execution timed out 1545 ms 29284 KB Time limit exceeded
49 Halted 0 ms 0 KB -