Submission #319490

# Submission time Handle Problem Language Result Execution time Memory
319490 2020-11-05T11:57:16 Z VEGAnn Painting Walls (APIO20_paint) C++14
51 / 100
1500 ms 28260 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], cnt[M];

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

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;

    int ptr = 0;

    for (int i = n - 1; i > n - m; i--){
        for (auto cr : inside[C[i]]){
            int loc = (ptr + cr.ft);

            if (loc >= m)
                loc -= m;

            cnt[loc]++;
        }

        ptr++;

        if (ptr == m) ptr = 0;
    }

    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;

        if (i + m < n){
            for (auto cr : inside[C[i + m]]){
                int loc = (ptr + cr.ft);

                if (loc >= m)
                    loc -= m;

                cnt[loc]--;
            }
        }

        bool ok = 0;

        for (auto cr : inside[C[i]]){
            int loc = (ptr + cr.ft);

            if (loc >= m)
                loc -= m;

            cnt[loc]++;

            if (cnt[loc] == m) ok = 1;
        }

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

        ptr++;

        if (ptr == m) ptr = 0;

//        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 21612 KB Output is correct
2 Correct 24 ms 21484 KB Output is correct
3 Correct 24 ms 21612 KB Output is correct
4 Correct 24 ms 21484 KB Output is correct
5 Correct 25 ms 21484 KB Output is correct
6 Correct 24 ms 21484 KB Output is correct
7 Correct 24 ms 21484 KB Output is correct
8 Correct 24 ms 21484 KB Output is correct
9 Correct 24 ms 21484 KB Output is correct
10 Correct 25 ms 21480 KB Output is correct
11 Correct 24 ms 21484 KB Output is correct
12 Correct 24 ms 21504 KB Output is correct
13 Correct 25 ms 21484 KB Output is correct
14 Correct 24 ms 21484 KB Output is correct
15 Correct 25 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 21612 KB Output is correct
19 Correct 24 ms 21484 KB Output is correct
20 Correct 25 ms 21484 KB Output is correct
21 Correct 25 ms 21480 KB Output is correct
22 Correct 61 ms 22252 KB Output is correct
23 Correct 62 ms 22244 KB Output is correct
24 Correct 61 ms 22272 KB Output is correct
25 Correct 26 ms 21740 KB Output is correct
26 Correct 27 ms 21772 KB Output is correct
27 Correct 26 ms 21740 KB Output is correct
28 Correct 26 ms 21760 KB Output is correct
29 Correct 26 ms 21740 KB Output is correct
30 Correct 27 ms 21728 KB Output is correct
31 Correct 84 ms 21996 KB Output is correct
32 Correct 83 ms 22068 KB Output is correct
33 Correct 83 ms 22008 KB Output is correct
34 Correct 83 ms 21988 KB Output is correct
35 Correct 83 ms 21988 KB Output is correct
36 Correct 84 ms 22116 KB Output is correct
37 Correct 109 ms 22628 KB Output is correct
38 Correct 104 ms 22756 KB Output is correct
39 Correct 106 ms 22628 KB Output is correct
40 Correct 35 ms 22508 KB Output is correct
41 Correct 31 ms 22252 KB Output is correct
42 Correct 34 ms 22756 KB Output is correct
43 Correct 31 ms 22252 KB Output is correct
44 Correct 30 ms 22252 KB Output is correct
45 Correct 34 ms 22636 KB Output is correct
46 Execution timed out 1546 ms 28260 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 21484 KB Output is correct
3 Correct 24 ms 21612 KB Output is correct
4 Correct 24 ms 21484 KB Output is correct
5 Correct 24 ms 21612 KB Output is correct
6 Correct 24 ms 21484 KB Output is correct
7 Correct 25 ms 21484 KB Output is correct
8 Correct 24 ms 21484 KB Output is correct
9 Correct 24 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 25 ms 21480 KB Output is correct
13 Correct 24 ms 21484 KB Output is correct
14 Correct 24 ms 21504 KB Output is correct
15 Correct 25 ms 21484 KB Output is correct
16 Correct 24 ms 21484 KB Output is correct
17 Correct 25 ms 21484 KB Output is correct
18 Correct 24 ms 21484 KB Output is correct
19 Correct 24 ms 21484 KB Output is correct
20 Correct 24 ms 21612 KB Output is correct
21 Correct 24 ms 21484 KB Output is correct
22 Correct 25 ms 21484 KB Output is correct
23 Correct 25 ms 21480 KB Output is correct
24 Correct 24 ms 21484 KB Output is correct
25 Correct 26 ms 21484 KB Output is correct
26 Correct 24 ms 21484 KB Output is correct
27 Correct 26 ms 21484 KB Output is correct
28 Correct 26 ms 21600 KB Output is correct
29 Correct 24 ms 21612 KB Output is correct
30 Correct 24 ms 21484 KB Output is correct
31 Correct 24 ms 21612 KB Output is correct
32 Correct 24 ms 21484 KB Output is correct
33 Correct 24 ms 21484 KB Output is correct
34 Correct 24 ms 21604 KB Output is correct
35 Correct 24 ms 21484 KB Output is correct
36 Correct 24 ms 21484 KB Output is correct
37 Correct 24 ms 21484 KB Output is correct
38 Correct 24 ms 21516 KB Output is correct
39 Correct 24 ms 21484 KB Output is correct
40 Correct 25 ms 21516 KB Output is correct
41 Correct 27 ms 21484 KB Output is correct
42 Correct 26 ms 21484 KB Output is correct
43 Correct 24 ms 21492 KB Output is correct
44 Correct 24 ms 21612 KB Output is correct
45 Correct 25 ms 21484 KB Output is correct
46 Correct 24 ms 21612 KB Output is correct
47 Correct 24 ms 21612 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 21484 KB Output is correct
51 Correct 24 ms 21484 KB Output is correct
52 Correct 24 ms 21484 KB Output is correct
53 Correct 24 ms 21484 KB Output is correct
54 Correct 25 ms 21484 KB Output is correct
55 Correct 24 ms 21612 KB Output is correct
56 Correct 25 ms 21476 KB Output is correct
57 Correct 24 ms 21584 KB Output is correct
58 Correct 24 ms 21484 KB Output is correct
59 Correct 24 ms 21484 KB Output is correct
60 Correct 25 ms 21484 KB Output is correct
61 Correct 27 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 21484 KB Output is correct
3 Correct 24 ms 21612 KB Output is correct
4 Correct 24 ms 21484 KB Output is correct
5 Correct 24 ms 21612 KB Output is correct
6 Correct 24 ms 21484 KB Output is correct
7 Correct 25 ms 21484 KB Output is correct
8 Correct 24 ms 21484 KB Output is correct
9 Correct 24 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 25 ms 21480 KB Output is correct
13 Correct 24 ms 21484 KB Output is correct
14 Correct 24 ms 21504 KB Output is correct
15 Correct 25 ms 21484 KB Output is correct
16 Correct 24 ms 21484 KB Output is correct
17 Correct 25 ms 21484 KB Output is correct
18 Correct 24 ms 21484 KB Output is correct
19 Correct 24 ms 21484 KB Output is correct
20 Correct 24 ms 21612 KB Output is correct
21 Correct 24 ms 21484 KB Output is correct
22 Correct 25 ms 21484 KB Output is correct
23 Correct 25 ms 21480 KB Output is correct
24 Correct 61 ms 22252 KB Output is correct
25 Correct 62 ms 22244 KB Output is correct
26 Correct 61 ms 22272 KB Output is correct
27 Correct 24 ms 21484 KB Output is correct
28 Correct 26 ms 21484 KB Output is correct
29 Correct 24 ms 21484 KB Output is correct
30 Correct 26 ms 21484 KB Output is correct
31 Correct 26 ms 21600 KB Output is correct
32 Correct 24 ms 21612 KB Output is correct
33 Correct 24 ms 21484 KB Output is correct
34 Correct 24 ms 21612 KB Output is correct
35 Correct 24 ms 21484 KB Output is correct
36 Correct 24 ms 21484 KB Output is correct
37 Correct 24 ms 21604 KB Output is correct
38 Correct 24 ms 21484 KB Output is correct
39 Correct 24 ms 21484 KB Output is correct
40 Correct 24 ms 21484 KB Output is correct
41 Correct 24 ms 21516 KB Output is correct
42 Correct 24 ms 21484 KB Output is correct
43 Correct 25 ms 21516 KB Output is correct
44 Correct 27 ms 21484 KB Output is correct
45 Correct 26 ms 21484 KB Output is correct
46 Correct 24 ms 21492 KB Output is correct
47 Correct 24 ms 21612 KB Output is correct
48 Correct 25 ms 21484 KB Output is correct
49 Correct 24 ms 21612 KB Output is correct
50 Correct 24 ms 21612 KB Output is correct
51 Correct 24 ms 21484 KB Output is correct
52 Correct 24 ms 21484 KB Output is correct
53 Correct 24 ms 21484 KB Output is correct
54 Correct 24 ms 21484 KB Output is correct
55 Correct 24 ms 21484 KB Output is correct
56 Correct 24 ms 21484 KB Output is correct
57 Correct 25 ms 21484 KB Output is correct
58 Correct 24 ms 21612 KB Output is correct
59 Correct 25 ms 21476 KB Output is correct
60 Correct 24 ms 21584 KB Output is correct
61 Correct 24 ms 21484 KB Output is correct
62 Correct 24 ms 21484 KB Output is correct
63 Correct 25 ms 21484 KB Output is correct
64 Correct 27 ms 21484 KB Output is correct
65 Correct 25 ms 21480 KB Output is correct
66 Correct 24 ms 21484 KB Output is correct
67 Correct 26 ms 21484 KB Output is correct
68 Correct 26 ms 21484 KB Output is correct
69 Correct 26 ms 21484 KB Output is correct
70 Correct 27 ms 21988 KB Output is correct
71 Correct 28 ms 21996 KB Output is correct
72 Correct 30 ms 21868 KB Output is correct
73 Correct 27 ms 21988 KB Output is correct
74 Correct 29 ms 22124 KB Output is correct
75 Correct 28 ms 21868 KB Output is correct
76 Correct 66 ms 23396 KB Output is correct
77 Correct 49 ms 22628 KB Output is correct
78 Correct 73 ms 23780 KB Output is correct
79 Correct 28 ms 21484 KB Output is correct
80 Correct 28 ms 21484 KB Output is correct
81 Correct 26 ms 21484 KB Output is correct
82 Correct 27 ms 21612 KB Output is correct
83 Correct 28 ms 21636 KB Output is correct
84 Correct 29 ms 21996 KB Output is correct
85 Correct 29 ms 22124 KB Output is correct
86 Correct 30 ms 21988 KB Output is correct
87 Correct 29 ms 21996 KB Output is correct
88 Correct 29 ms 22124 KB Output is correct
89 Correct 29 ms 21996 KB Output is correct
90 Correct 81 ms 24164 KB Output is correct
91 Correct 80 ms 24168 KB Output is correct
92 Correct 84 ms 24068 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 24 ms 21484 KB Output is correct
2 Correct 24 ms 21484 KB Output is correct
3 Correct 24 ms 21612 KB Output is correct
4 Correct 24 ms 21484 KB Output is correct
5 Correct 24 ms 21612 KB Output is correct
6 Correct 24 ms 21484 KB Output is correct
7 Correct 25 ms 21484 KB Output is correct
8 Correct 24 ms 21484 KB Output is correct
9 Correct 24 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 25 ms 21480 KB Output is correct
13 Correct 24 ms 21484 KB Output is correct
14 Correct 24 ms 21504 KB Output is correct
15 Correct 25 ms 21484 KB Output is correct
16 Correct 24 ms 21484 KB Output is correct
17 Correct 25 ms 21484 KB Output is correct
18 Correct 24 ms 21484 KB Output is correct
19 Correct 24 ms 21484 KB Output is correct
20 Correct 24 ms 21612 KB Output is correct
21 Correct 24 ms 21484 KB Output is correct
22 Correct 25 ms 21484 KB Output is correct
23 Correct 25 ms 21480 KB Output is correct
24 Correct 61 ms 22252 KB Output is correct
25 Correct 62 ms 22244 KB Output is correct
26 Correct 61 ms 22272 KB Output is correct
27 Correct 26 ms 21740 KB Output is correct
28 Correct 27 ms 21772 KB Output is correct
29 Correct 26 ms 21740 KB Output is correct
30 Correct 26 ms 21760 KB Output is correct
31 Correct 26 ms 21740 KB Output is correct
32 Correct 27 ms 21728 KB Output is correct
33 Correct 84 ms 21996 KB Output is correct
34 Correct 83 ms 22068 KB Output is correct
35 Correct 83 ms 22008 KB Output is correct
36 Correct 83 ms 21988 KB Output is correct
37 Correct 83 ms 21988 KB Output is correct
38 Correct 84 ms 22116 KB Output is correct
39 Correct 109 ms 22628 KB Output is correct
40 Correct 104 ms 22756 KB Output is correct
41 Correct 106 ms 22628 KB Output is correct
42 Correct 24 ms 21484 KB Output is correct
43 Correct 26 ms 21484 KB Output is correct
44 Correct 24 ms 21484 KB Output is correct
45 Correct 26 ms 21484 KB Output is correct
46 Correct 26 ms 21600 KB Output is correct
47 Correct 24 ms 21612 KB Output is correct
48 Correct 24 ms 21484 KB Output is correct
49 Correct 24 ms 21612 KB Output is correct
50 Correct 24 ms 21484 KB Output is correct
51 Correct 24 ms 21484 KB Output is correct
52 Correct 24 ms 21604 KB Output is correct
53 Correct 24 ms 21484 KB Output is correct
54 Correct 24 ms 21484 KB Output is correct
55 Correct 24 ms 21484 KB Output is correct
56 Correct 24 ms 21516 KB Output is correct
57 Correct 24 ms 21484 KB Output is correct
58 Correct 25 ms 21516 KB Output is correct
59 Correct 27 ms 21484 KB Output is correct
60 Correct 26 ms 21484 KB Output is correct
61 Correct 24 ms 21492 KB Output is correct
62 Correct 24 ms 21612 KB Output is correct
63 Correct 25 ms 21484 KB Output is correct
64 Correct 24 ms 21612 KB Output is correct
65 Correct 24 ms 21612 KB Output is correct
66 Correct 24 ms 21484 KB Output is correct
67 Correct 24 ms 21484 KB Output is correct
68 Correct 24 ms 21484 KB Output is correct
69 Correct 24 ms 21484 KB Output is correct
70 Correct 24 ms 21484 KB Output is correct
71 Correct 24 ms 21484 KB Output is correct
72 Correct 25 ms 21484 KB Output is correct
73 Correct 24 ms 21612 KB Output is correct
74 Correct 25 ms 21476 KB Output is correct
75 Correct 24 ms 21584 KB Output is correct
76 Correct 24 ms 21484 KB Output is correct
77 Correct 24 ms 21484 KB Output is correct
78 Correct 25 ms 21484 KB Output is correct
79 Correct 27 ms 21484 KB Output is correct
80 Correct 25 ms 21480 KB Output is correct
81 Correct 24 ms 21484 KB Output is correct
82 Correct 26 ms 21484 KB Output is correct
83 Correct 26 ms 21484 KB Output is correct
84 Correct 26 ms 21484 KB Output is correct
85 Correct 27 ms 21988 KB Output is correct
86 Correct 28 ms 21996 KB Output is correct
87 Correct 30 ms 21868 KB Output is correct
88 Correct 27 ms 21988 KB Output is correct
89 Correct 29 ms 22124 KB Output is correct
90 Correct 28 ms 21868 KB Output is correct
91 Correct 66 ms 23396 KB Output is correct
92 Correct 49 ms 22628 KB Output is correct
93 Correct 73 ms 23780 KB Output is correct
94 Correct 28 ms 21484 KB Output is correct
95 Correct 28 ms 21484 KB Output is correct
96 Correct 26 ms 21484 KB Output is correct
97 Correct 27 ms 21612 KB Output is correct
98 Correct 28 ms 21636 KB Output is correct
99 Correct 29 ms 21996 KB Output is correct
100 Correct 29 ms 22124 KB Output is correct
101 Correct 30 ms 21988 KB Output is correct
102 Correct 29 ms 21996 KB Output is correct
103 Correct 29 ms 22124 KB Output is correct
104 Correct 29 ms 21996 KB Output is correct
105 Correct 81 ms 24164 KB Output is correct
106 Correct 80 ms 24168 KB Output is correct
107 Correct 84 ms 24068 KB Output is correct
108 Correct 27 ms 21740 KB Output is correct
109 Correct 189 ms 21868 KB Output is correct
110 Correct 38 ms 21868 KB Output is correct
111 Correct 37 ms 21740 KB Output is correct
112 Correct 42 ms 21868 KB Output is correct
113 Correct 41 ms 21740 KB Output is correct
114 Correct 69 ms 24164 KB Output is correct
115 Correct 56 ms 23908 KB Output is correct
116 Correct 87 ms 25444 KB Output is correct
117 Correct 64 ms 24172 KB Output is correct
118 Correct 60 ms 24420 KB Output is correct
119 Correct 71 ms 22244 KB Output is correct
120 Correct 80 ms 23140 KB Output is correct
121 Correct 55 ms 21868 KB Output is correct
122 Correct 74 ms 24164 KB Output is correct
123 Correct 38 ms 21740 KB Output is correct
124 Correct 74 ms 24036 KB Output is correct
125 Correct 39 ms 21868 KB Output is correct
126 Correct 37 ms 21868 KB Output is correct
127 Correct 53 ms 21992 KB Output is correct
128 Correct 39 ms 21868 KB Output is correct
129 Correct 40 ms 21860 KB Output is correct
130 Correct 27 ms 21740 KB Output is correct
131 Correct 259 ms 21988 KB Output is correct
132 Correct 48 ms 21868 KB Output is correct
133 Correct 52 ms 21868 KB Output is correct
134 Correct 53 ms 21988 KB Output is correct
135 Correct 57 ms 21868 KB Output is correct
136 Correct 116 ms 26084 KB Output is correct
137 Correct 117 ms 26596 KB Output is correct
138 Correct 116 ms 26468 KB Output is correct
139 Correct 117 ms 26468 KB Output is correct
140 Correct 119 ms 26596 KB Output is correct
141 Correct 118 ms 26584 KB Output is correct
142 Correct 130 ms 25568 KB Output is correct
143 Correct 80 ms 22244 KB Output is correct
144 Correct 128 ms 25572 KB Output is correct
145 Correct 80 ms 22372 KB Output is correct
146 Correct 127 ms 25572 KB Output is correct
147 Correct 82 ms 22372 KB Output is correct
148 Correct 86 ms 22380 KB Output is correct
149 Correct 68 ms 22380 KB Output is correct
150 Correct 59 ms 22252 KB Output is correct
151 Correct 56 ms 22244 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 24 ms 21484 KB Output is correct
2 Correct 24 ms 21484 KB Output is correct
3 Correct 24 ms 21612 KB Output is correct
4 Correct 24 ms 21484 KB Output is correct
5 Correct 24 ms 21612 KB Output is correct
6 Correct 24 ms 21484 KB Output is correct
7 Correct 25 ms 21484 KB Output is correct
8 Correct 24 ms 21484 KB Output is correct
9 Correct 24 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 25 ms 21480 KB Output is correct
13 Correct 24 ms 21484 KB Output is correct
14 Correct 24 ms 21504 KB Output is correct
15 Correct 25 ms 21484 KB Output is correct
16 Correct 24 ms 21484 KB Output is correct
17 Correct 25 ms 21484 KB Output is correct
18 Correct 24 ms 21484 KB Output is correct
19 Correct 24 ms 21484 KB Output is correct
20 Correct 24 ms 21612 KB Output is correct
21 Correct 24 ms 21484 KB Output is correct
22 Correct 25 ms 21484 KB Output is correct
23 Correct 25 ms 21480 KB Output is correct
24 Correct 61 ms 22252 KB Output is correct
25 Correct 62 ms 22244 KB Output is correct
26 Correct 61 ms 22272 KB Output is correct
27 Correct 26 ms 21740 KB Output is correct
28 Correct 27 ms 21772 KB Output is correct
29 Correct 26 ms 21740 KB Output is correct
30 Correct 26 ms 21760 KB Output is correct
31 Correct 26 ms 21740 KB Output is correct
32 Correct 27 ms 21728 KB Output is correct
33 Correct 84 ms 21996 KB Output is correct
34 Correct 83 ms 22068 KB Output is correct
35 Correct 83 ms 22008 KB Output is correct
36 Correct 83 ms 21988 KB Output is correct
37 Correct 83 ms 21988 KB Output is correct
38 Correct 84 ms 22116 KB Output is correct
39 Correct 109 ms 22628 KB Output is correct
40 Correct 104 ms 22756 KB Output is correct
41 Correct 106 ms 22628 KB Output is correct
42 Correct 35 ms 22508 KB Output is correct
43 Correct 31 ms 22252 KB Output is correct
44 Correct 34 ms 22756 KB Output is correct
45 Correct 31 ms 22252 KB Output is correct
46 Correct 30 ms 22252 KB Output is correct
47 Correct 34 ms 22636 KB Output is correct
48 Execution timed out 1546 ms 28260 KB Time limit exceeded
49 Halted 0 ms 0 KB -