Submission #1106231

# Submission time Handle Problem Language Result Execution time Memory
1106231 2024-10-29T15:26:24 Z vladilius Painting Walls (APIO20_paint) C++17
51 / 100
1095 ms 524288 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define pb push_back
#define ff first
#define ss second
 
int minimumInstructions(int n, int m, int k, vector<int> x, vector<int> A, vector<vector<int>> B){
    vector<vector<bool>> f(m, vector<bool>(k));
    for (int i = 0; i < m; i++){
        for (int j: B[i]){
            f[i][j] = 1;
        }
    }
    vector<int> T[n];
    for (int i = 0; i < n; i++){
        for (int j = 0; j < m; j++){
            if (f[j][x[i]]){
                T[i].pb(j);
            }
        }
        int q = (int) T[i].size();
        for (int j = 0; j < q; j++){
            T[i].pb(T[i][j] + m);
        }
        
        for (int j = 0; j < T[i].size(); j++) T[i][j] -= i;
    }
    
    map<int, vector<int>> mp;
    for (int i = 0; i < n; i++){
        for (int j: T[i]){
            mp[j].pb(i);
        }
    }
    
    vector<bool> gd(n);
    for (auto [y, V]: mp){
        int i = 0;
        while (i < V.size()){
            int j = i;
            while (j + 1 < V.size() && (V[j] + 1) == V[j + 1]) j++;
            for (int t = V[i]; t <= V[j] - m + 1; t++) gd[t] = 1;
            
            i = j + 1;
        }
    }
    
    int mx = -1, t = -1, out = 0;
    for (int i = 0; i < n; i++){
        if (gd[i]) t = max(t, i);
        if (i == (mx + 1)){
            if (t == -1) return -1;
            mx = t + m - 1;
            t = -1;
            out++;
        }
    }
    return out;
}

Compilation message

paint.cpp: In function 'int minimumInstructions(int, int, int, std::vector<int>, std::vector<int>, std::vector<std::vector<int> >)':
paint.cpp:28:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |         for (int j = 0; j < T[i].size(); j++) T[i][j] -= i;
      |                         ~~^~~~~~~~~~~~~
paint.cpp:41:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |         while (i < V.size()){
      |                ~~^~~~~~~~~~
paint.cpp:43:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |             while (j + 1 < V.size() && (V[j] + 1) == V[j + 1]) j++;
      |                    ~~~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 504 KB Output is correct
5 Correct 0 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 504 KB Output is correct
13 Correct 3 ms 3064 KB Output is correct
14 Correct 3 ms 2896 KB Output is correct
15 Correct 3 ms 2896 KB Output is correct
16 Correct 2 ms 2828 KB Output is correct
17 Correct 3 ms 2896 KB Output is correct
18 Correct 3 ms 2896 KB Output is correct
19 Correct 3 ms 2896 KB Output is correct
20 Correct 2 ms 2896 KB Output is correct
21 Correct 3 ms 2896 KB Output is correct
22 Correct 9 ms 3636 KB Output is correct
23 Correct 9 ms 3836 KB Output is correct
24 Correct 10 ms 3664 KB Output is correct
25 Correct 8 ms 3664 KB Output is correct
26 Correct 9 ms 3864 KB Output is correct
27 Correct 9 ms 3832 KB Output is correct
28 Correct 9 ms 3664 KB Output is correct
29 Correct 10 ms 3664 KB Output is correct
30 Correct 9 ms 3408 KB Output is correct
31 Correct 239 ms 26704 KB Output is correct
32 Correct 259 ms 26696 KB Output is correct
33 Correct 242 ms 26648 KB Output is correct
34 Correct 275 ms 26696 KB Output is correct
35 Correct 235 ms 26696 KB Output is correct
36 Correct 203 ms 26696 KB Output is correct
37 Correct 252 ms 29000 KB Output is correct
38 Correct 244 ms 29008 KB Output is correct
39 Correct 243 ms 29000 KB Output is correct
40 Correct 42 ms 15944 KB Output is correct
41 Correct 25 ms 10136 KB Output is correct
42 Correct 41 ms 16664 KB Output is correct
43 Correct 28 ms 10832 KB Output is correct
44 Correct 29 ms 9808 KB Output is correct
45 Correct 49 ms 16468 KB Output is correct
46 Runtime error 339 ms 524288 KB Execution killed with signal 9
47 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 504 KB Output is correct
5 Correct 0 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 504 KB Output is correct
13 Correct 3 ms 3064 KB Output is correct
14 Correct 3 ms 2896 KB Output is correct
15 Correct 3 ms 2896 KB Output is correct
16 Correct 2 ms 2828 KB Output is correct
17 Correct 3 ms 2896 KB Output is correct
18 Correct 3 ms 2896 KB Output is correct
19 Correct 3 ms 2896 KB Output is correct
20 Correct 2 ms 2896 KB Output is correct
21 Correct 3 ms 2896 KB Output is correct
22 Correct 1 ms 336 KB Output is correct
23 Correct 1 ms 336 KB Output is correct
24 Correct 0 ms 336 KB Output is correct
25 Correct 1 ms 336 KB Output is correct
26 Correct 1 ms 336 KB Output is correct
27 Correct 1 ms 336 KB Output is correct
28 Correct 1 ms 592 KB Output is correct
29 Correct 1 ms 336 KB Output is correct
30 Correct 1 ms 336 KB Output is correct
31 Correct 1 ms 336 KB Output is correct
32 Correct 1 ms 592 KB Output is correct
33 Correct 2 ms 2128 KB Output is correct
34 Correct 2 ms 1616 KB Output is correct
35 Correct 1 ms 1360 KB Output is correct
36 Correct 2 ms 2128 KB Output is correct
37 Correct 2 ms 2128 KB Output is correct
38 Correct 1 ms 336 KB Output is correct
39 Correct 1 ms 336 KB Output is correct
40 Correct 2 ms 1872 KB Output is correct
41 Correct 1 ms 336 KB Output is correct
42 Correct 2 ms 1360 KB Output is correct
43 Correct 1 ms 848 KB Output is correct
44 Correct 1 ms 336 KB Output is correct
45 Correct 2 ms 696 KB Output is correct
46 Correct 2 ms 592 KB Output is correct
47 Correct 2 ms 592 KB Output is correct
48 Correct 2 ms 592 KB Output is correct
49 Correct 2 ms 592 KB Output is correct
50 Correct 2 ms 2748 KB Output is correct
51 Correct 3 ms 2896 KB Output is correct
52 Correct 3 ms 2896 KB Output is correct
53 Correct 3 ms 2896 KB Output is correct
54 Correct 2 ms 2896 KB Output is correct
55 Correct 2 ms 3068 KB Output is correct
56 Correct 3 ms 3064 KB Output is correct
57 Correct 1 ms 348 KB Output is correct
58 Correct 3 ms 2896 KB Output is correct
59 Correct 1 ms 336 KB Output is correct
60 Correct 3 ms 2896 KB Output is correct
61 Correct 1 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 504 KB Output is correct
7 Correct 0 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 504 KB Output is correct
15 Correct 3 ms 3064 KB Output is correct
16 Correct 3 ms 2896 KB Output is correct
17 Correct 3 ms 2896 KB Output is correct
18 Correct 2 ms 2828 KB Output is correct
19 Correct 3 ms 2896 KB Output is correct
20 Correct 3 ms 2896 KB Output is correct
21 Correct 3 ms 2896 KB Output is correct
22 Correct 2 ms 2896 KB Output is correct
23 Correct 3 ms 2896 KB Output is correct
24 Correct 9 ms 3636 KB Output is correct
25 Correct 9 ms 3836 KB Output is correct
26 Correct 10 ms 3664 KB Output is correct
27 Correct 0 ms 336 KB Output is correct
28 Correct 1 ms 336 KB Output is correct
29 Correct 1 ms 336 KB Output is correct
30 Correct 1 ms 336 KB Output is correct
31 Correct 1 ms 592 KB Output is correct
32 Correct 1 ms 336 KB Output is correct
33 Correct 1 ms 336 KB Output is correct
34 Correct 1 ms 336 KB Output is correct
35 Correct 1 ms 592 KB Output is correct
36 Correct 2 ms 2128 KB Output is correct
37 Correct 2 ms 1616 KB Output is correct
38 Correct 1 ms 1360 KB Output is correct
39 Correct 2 ms 2128 KB Output is correct
40 Correct 2 ms 2128 KB Output is correct
41 Correct 1 ms 336 KB Output is correct
42 Correct 1 ms 336 KB Output is correct
43 Correct 2 ms 1872 KB Output is correct
44 Correct 1 ms 336 KB Output is correct
45 Correct 2 ms 1360 KB Output is correct
46 Correct 1 ms 848 KB Output is correct
47 Correct 1 ms 336 KB Output is correct
48 Correct 2 ms 696 KB Output is correct
49 Correct 2 ms 592 KB Output is correct
50 Correct 2 ms 592 KB Output is correct
51 Correct 2 ms 592 KB Output is correct
52 Correct 2 ms 592 KB Output is correct
53 Correct 2 ms 2748 KB Output is correct
54 Correct 3 ms 2896 KB Output is correct
55 Correct 3 ms 2896 KB Output is correct
56 Correct 3 ms 2896 KB Output is correct
57 Correct 2 ms 2896 KB Output is correct
58 Correct 2 ms 3068 KB Output is correct
59 Correct 3 ms 3064 KB Output is correct
60 Correct 1 ms 348 KB Output is correct
61 Correct 3 ms 2896 KB Output is correct
62 Correct 1 ms 336 KB Output is correct
63 Correct 3 ms 2896 KB Output is correct
64 Correct 1 ms 336 KB Output is correct
65 Correct 3 ms 1360 KB Output is correct
66 Correct 2 ms 848 KB Output is correct
67 Correct 4 ms 1616 KB Output is correct
68 Correct 3 ms 1528 KB Output is correct
69 Correct 3 ms 1360 KB Output is correct
70 Correct 3 ms 2592 KB Output is correct
71 Correct 3 ms 2300 KB Output is correct
72 Correct 3 ms 1372 KB Output is correct
73 Correct 2 ms 592 KB Output is correct
74 Correct 3 ms 1656 KB Output is correct
75 Correct 4 ms 2896 KB Output is correct
76 Correct 9 ms 2896 KB Output is correct
77 Correct 9 ms 2128 KB Output is correct
78 Correct 11 ms 2736 KB Output is correct
79 Correct 5 ms 2640 KB Output is correct
80 Correct 9 ms 2760 KB Output is correct
81 Correct 6 ms 2624 KB Output is correct
82 Correct 6 ms 2640 KB Output is correct
83 Correct 6 ms 2640 KB Output is correct
84 Correct 4 ms 3408 KB Output is correct
85 Correct 4 ms 3408 KB Output is correct
86 Correct 4 ms 3264 KB Output is correct
87 Correct 4 ms 3380 KB Output is correct
88 Correct 5 ms 3408 KB Output is correct
89 Correct 4 ms 3408 KB Output is correct
90 Correct 13 ms 4944 KB Output is correct
91 Correct 13 ms 5024 KB Output is correct
92 Correct 13 ms 4944 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 504 KB Output is correct
7 Correct 0 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 504 KB Output is correct
15 Correct 3 ms 3064 KB Output is correct
16 Correct 3 ms 2896 KB Output is correct
17 Correct 3 ms 2896 KB Output is correct
18 Correct 2 ms 2828 KB Output is correct
19 Correct 3 ms 2896 KB Output is correct
20 Correct 3 ms 2896 KB Output is correct
21 Correct 3 ms 2896 KB Output is correct
22 Correct 2 ms 2896 KB Output is correct
23 Correct 3 ms 2896 KB Output is correct
24 Correct 9 ms 3636 KB Output is correct
25 Correct 9 ms 3836 KB Output is correct
26 Correct 10 ms 3664 KB Output is correct
27 Correct 8 ms 3664 KB Output is correct
28 Correct 9 ms 3864 KB Output is correct
29 Correct 9 ms 3832 KB Output is correct
30 Correct 9 ms 3664 KB Output is correct
31 Correct 10 ms 3664 KB Output is correct
32 Correct 9 ms 3408 KB Output is correct
33 Correct 239 ms 26704 KB Output is correct
34 Correct 259 ms 26696 KB Output is correct
35 Correct 242 ms 26648 KB Output is correct
36 Correct 275 ms 26696 KB Output is correct
37 Correct 235 ms 26696 KB Output is correct
38 Correct 203 ms 26696 KB Output is correct
39 Correct 252 ms 29000 KB Output is correct
40 Correct 244 ms 29008 KB Output is correct
41 Correct 243 ms 29000 KB Output is correct
42 Correct 0 ms 336 KB Output is correct
43 Correct 1 ms 336 KB Output is correct
44 Correct 1 ms 336 KB Output is correct
45 Correct 1 ms 336 KB Output is correct
46 Correct 1 ms 592 KB Output is correct
47 Correct 1 ms 336 KB Output is correct
48 Correct 1 ms 336 KB Output is correct
49 Correct 1 ms 336 KB Output is correct
50 Correct 1 ms 592 KB Output is correct
51 Correct 2 ms 2128 KB Output is correct
52 Correct 2 ms 1616 KB Output is correct
53 Correct 1 ms 1360 KB Output is correct
54 Correct 2 ms 2128 KB Output is correct
55 Correct 2 ms 2128 KB Output is correct
56 Correct 1 ms 336 KB Output is correct
57 Correct 1 ms 336 KB Output is correct
58 Correct 2 ms 1872 KB Output is correct
59 Correct 1 ms 336 KB Output is correct
60 Correct 2 ms 1360 KB Output is correct
61 Correct 1 ms 848 KB Output is correct
62 Correct 1 ms 336 KB Output is correct
63 Correct 2 ms 696 KB Output is correct
64 Correct 2 ms 592 KB Output is correct
65 Correct 2 ms 592 KB Output is correct
66 Correct 2 ms 592 KB Output is correct
67 Correct 2 ms 592 KB Output is correct
68 Correct 2 ms 2748 KB Output is correct
69 Correct 3 ms 2896 KB Output is correct
70 Correct 3 ms 2896 KB Output is correct
71 Correct 3 ms 2896 KB Output is correct
72 Correct 2 ms 2896 KB Output is correct
73 Correct 2 ms 3068 KB Output is correct
74 Correct 3 ms 3064 KB Output is correct
75 Correct 1 ms 348 KB Output is correct
76 Correct 3 ms 2896 KB Output is correct
77 Correct 1 ms 336 KB Output is correct
78 Correct 3 ms 2896 KB Output is correct
79 Correct 1 ms 336 KB Output is correct
80 Correct 3 ms 1360 KB Output is correct
81 Correct 2 ms 848 KB Output is correct
82 Correct 4 ms 1616 KB Output is correct
83 Correct 3 ms 1528 KB Output is correct
84 Correct 3 ms 1360 KB Output is correct
85 Correct 3 ms 2592 KB Output is correct
86 Correct 3 ms 2300 KB Output is correct
87 Correct 3 ms 1372 KB Output is correct
88 Correct 2 ms 592 KB Output is correct
89 Correct 3 ms 1656 KB Output is correct
90 Correct 4 ms 2896 KB Output is correct
91 Correct 9 ms 2896 KB Output is correct
92 Correct 9 ms 2128 KB Output is correct
93 Correct 11 ms 2736 KB Output is correct
94 Correct 5 ms 2640 KB Output is correct
95 Correct 9 ms 2760 KB Output is correct
96 Correct 6 ms 2624 KB Output is correct
97 Correct 6 ms 2640 KB Output is correct
98 Correct 6 ms 2640 KB Output is correct
99 Correct 4 ms 3408 KB Output is correct
100 Correct 4 ms 3408 KB Output is correct
101 Correct 4 ms 3264 KB Output is correct
102 Correct 4 ms 3380 KB Output is correct
103 Correct 5 ms 3408 KB Output is correct
104 Correct 4 ms 3408 KB Output is correct
105 Correct 13 ms 4944 KB Output is correct
106 Correct 13 ms 5024 KB Output is correct
107 Correct 13 ms 4944 KB Output is correct
108 Correct 12 ms 3664 KB Output is correct
109 Correct 671 ms 234188 KB Output is correct
110 Correct 543 ms 101704 KB Output is correct
111 Correct 457 ms 94536 KB Output is correct
112 Correct 573 ms 122704 KB Output is correct
113 Correct 392 ms 61768 KB Output is correct
114 Correct 55 ms 15108 KB Output is correct
115 Correct 13 ms 4176 KB Output is correct
116 Correct 52 ms 12108 KB Output is correct
117 Correct 34 ms 8988 KB Output is correct
118 Correct 17 ms 4776 KB Output is correct
119 Correct 106 ms 20304 KB Output is correct
120 Correct 135 ms 19116 KB Output is correct
121 Correct 65 ms 5752 KB Output is correct
122 Correct 36 ms 8024 KB Output is correct
123 Correct 23 ms 3408 KB Output is correct
124 Correct 28 ms 6728 KB Output is correct
125 Correct 18 ms 4432 KB Output is correct
126 Correct 8 ms 2384 KB Output is correct
127 Correct 34 ms 7752 KB Output is correct
128 Correct 10 ms 3152 KB Output is correct
129 Correct 13 ms 3152 KB Output is correct
130 Correct 12 ms 3932 KB Output is correct
131 Correct 974 ms 323260 KB Output is correct
132 Correct 1095 ms 165384 KB Output is correct
133 Correct 1006 ms 164700 KB Output is correct
134 Correct 928 ms 163588 KB Output is correct
135 Correct 865 ms 154228 KB Output is correct
136 Correct 256 ms 28488 KB Output is correct
137 Correct 247 ms 28488 KB Output is correct
138 Correct 219 ms 28640 KB Output is correct
139 Correct 245 ms 28504 KB Output is correct
140 Correct 233 ms 28516 KB Output is correct
141 Correct 238 ms 28568 KB Output is correct
142 Correct 215 ms 30792 KB Output is correct
143 Correct 113 ms 9288 KB Output is correct
144 Correct 235 ms 30788 KB Output is correct
145 Correct 114 ms 9484 KB Output is correct
146 Correct 238 ms 31072 KB Output is correct
147 Correct 115 ms 9464 KB Output is correct
148 Correct 239 ms 27156 KB Output is correct
149 Correct 93 ms 14920 KB Output is correct
150 Correct 57 ms 10616 KB Output is correct
151 Correct 39 ms 8528 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 504 KB Output is correct
7 Correct 0 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 504 KB Output is correct
15 Correct 3 ms 3064 KB Output is correct
16 Correct 3 ms 2896 KB Output is correct
17 Correct 3 ms 2896 KB Output is correct
18 Correct 2 ms 2828 KB Output is correct
19 Correct 3 ms 2896 KB Output is correct
20 Correct 3 ms 2896 KB Output is correct
21 Correct 3 ms 2896 KB Output is correct
22 Correct 2 ms 2896 KB Output is correct
23 Correct 3 ms 2896 KB Output is correct
24 Correct 9 ms 3636 KB Output is correct
25 Correct 9 ms 3836 KB Output is correct
26 Correct 10 ms 3664 KB Output is correct
27 Correct 8 ms 3664 KB Output is correct
28 Correct 9 ms 3864 KB Output is correct
29 Correct 9 ms 3832 KB Output is correct
30 Correct 9 ms 3664 KB Output is correct
31 Correct 10 ms 3664 KB Output is correct
32 Correct 9 ms 3408 KB Output is correct
33 Correct 239 ms 26704 KB Output is correct
34 Correct 259 ms 26696 KB Output is correct
35 Correct 242 ms 26648 KB Output is correct
36 Correct 275 ms 26696 KB Output is correct
37 Correct 235 ms 26696 KB Output is correct
38 Correct 203 ms 26696 KB Output is correct
39 Correct 252 ms 29000 KB Output is correct
40 Correct 244 ms 29008 KB Output is correct
41 Correct 243 ms 29000 KB Output is correct
42 Correct 42 ms 15944 KB Output is correct
43 Correct 25 ms 10136 KB Output is correct
44 Correct 41 ms 16664 KB Output is correct
45 Correct 28 ms 10832 KB Output is correct
46 Correct 29 ms 9808 KB Output is correct
47 Correct 49 ms 16468 KB Output is correct
48 Runtime error 339 ms 524288 KB Execution killed with signal 9
49 Halted 0 ms 0 KB -