Submission #1000197

# Submission time Handle Problem Language Result Execution time Memory
1000197 2024-06-17T02:30:48 Z abczz Painting Walls (APIO20_paint) C++17
51 / 100
1500 ms 7784 KB
#include "paint.h"
#include <iostream>
#include <vector>
#include <queue>
#include <array>
#include <algorithm>
#define ll int

using namespace std;

ll p = -1, dp[2][50000], ver[2][50000];
vector <ll> color[100000], V;
bool X[100000];
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) {
      color[B[i][j]].push_back(i);
    }
  }
  for (int i=0; i<N; ++i) {
    for (auto u : color[C[i]]) {
      if (ver[0][(u+M-1)%M] == i) {
        dp[1][u] = dp[0][(u+M-1)%M] + 1;
        if (dp[1][u] >= M) X[i-M+1] = 1;
      }
      else dp[1][u] = 1;
      ver[1][u] = i+1;
    }
    swap(dp[0], dp[1]);
    swap(ver[0], ver[1]);
  }
  for (int i=0; i<N; ++i) {
    if (X[i]) V.push_back(i);
  }
  p = 0;
  int f = 0;
  while (p < N) {
    auto it = lower_bound(V.begin(), V.end(), p+1);
    if (it == V.begin()) return -1;
    it = prev(it);
    if (*it+M <= p) return -1;
    p = *it+M;
    ++f;
  }
  return f;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 3420 KB Output is correct
2 Correct 1 ms 3420 KB Output is correct
3 Correct 1 ms 3420 KB Output is correct
4 Correct 1 ms 3420 KB Output is correct
5 Correct 1 ms 3420 KB Output is correct
6 Correct 1 ms 3420 KB Output is correct
7 Correct 35 ms 3416 KB Output is correct
8 Correct 35 ms 3420 KB Output is correct
9 Correct 36 ms 3420 KB Output is correct
10 Correct 35 ms 3420 KB Output is correct
11 Correct 35 ms 3416 KB Output is correct
12 Correct 35 ms 3420 KB Output is correct
13 Correct 35 ms 3420 KB Output is correct
14 Correct 37 ms 3420 KB Output is correct
15 Correct 35 ms 3416 KB Output is correct
16 Correct 35 ms 3416 KB Output is correct
17 Correct 35 ms 3420 KB Output is correct
18 Correct 35 ms 3416 KB Output is correct
19 Correct 35 ms 3416 KB Output is correct
20 Correct 37 ms 3420 KB Output is correct
21 Correct 37 ms 3420 KB Output is correct
22 Correct 45 ms 7256 KB Output is correct
23 Correct 47 ms 7256 KB Output is correct
24 Correct 46 ms 7260 KB Output is correct
25 Correct 1347 ms 3924 KB Output is correct
26 Correct 1327 ms 3700 KB Output is correct
27 Correct 1363 ms 3716 KB Output is correct
28 Correct 1340 ms 3676 KB Output is correct
29 Correct 1318 ms 3924 KB Output is correct
30 Correct 1363 ms 3672 KB Output is correct
31 Correct 1363 ms 4692 KB Output is correct
32 Correct 1315 ms 4688 KB Output is correct
33 Correct 1274 ms 4636 KB Output is correct
34 Correct 1385 ms 4688 KB Output is correct
35 Correct 1331 ms 4692 KB Output is correct
36 Correct 1479 ms 4628 KB Output is correct
37 Correct 1381 ms 7784 KB Output is correct
38 Correct 1369 ms 7768 KB Output is correct
39 Correct 1442 ms 7784 KB Output is correct
40 Execution timed out 1558 ms 4288 KB Time limit exceeded
41 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 3420 KB Output is correct
2 Correct 1 ms 3420 KB Output is correct
3 Correct 1 ms 3420 KB Output is correct
4 Correct 1 ms 3420 KB Output is correct
5 Correct 1 ms 3420 KB Output is correct
6 Correct 1 ms 3420 KB Output is correct
7 Correct 35 ms 3416 KB Output is correct
8 Correct 35 ms 3420 KB Output is correct
9 Correct 36 ms 3420 KB Output is correct
10 Correct 35 ms 3420 KB Output is correct
11 Correct 35 ms 3416 KB Output is correct
12 Correct 35 ms 3420 KB Output is correct
13 Correct 35 ms 3420 KB Output is correct
14 Correct 37 ms 3420 KB Output is correct
15 Correct 35 ms 3416 KB Output is correct
16 Correct 35 ms 3416 KB Output is correct
17 Correct 35 ms 3420 KB Output is correct
18 Correct 35 ms 3416 KB Output is correct
19 Correct 35 ms 3416 KB Output is correct
20 Correct 37 ms 3420 KB Output is correct
21 Correct 37 ms 3420 KB Output is correct
22 Correct 2 ms 3420 KB Output is correct
23 Correct 1 ms 3420 KB Output is correct
24 Correct 1 ms 3420 KB Output is correct
25 Correct 1 ms 3420 KB Output is correct
26 Correct 1 ms 3420 KB Output is correct
27 Correct 20 ms 3564 KB Output is correct
28 Correct 23 ms 3420 KB Output is correct
29 Correct 18 ms 3580 KB Output is correct
30 Correct 25 ms 3420 KB Output is correct
31 Correct 34 ms 3420 KB Output is correct
32 Correct 31 ms 3420 KB Output is correct
33 Correct 29 ms 3420 KB Output is correct
34 Correct 31 ms 3420 KB Output is correct
35 Correct 21 ms 3420 KB Output is correct
36 Correct 26 ms 3604 KB Output is correct
37 Correct 23 ms 3608 KB Output is correct
38 Correct 22 ms 3420 KB Output is correct
39 Correct 21 ms 3420 KB Output is correct
40 Correct 20 ms 3416 KB Output is correct
41 Correct 25 ms 3420 KB Output is correct
42 Correct 30 ms 3420 KB Output is correct
43 Correct 22 ms 3592 KB Output is correct
44 Correct 35 ms 3420 KB Output is correct
45 Correct 35 ms 3420 KB Output is correct
46 Correct 35 ms 3416 KB Output is correct
47 Correct 45 ms 3420 KB Output is correct
48 Correct 34 ms 3416 KB Output is correct
49 Correct 35 ms 3420 KB Output is correct
50 Correct 38 ms 3420 KB Output is correct
51 Correct 35 ms 3420 KB Output is correct
52 Correct 35 ms 3416 KB Output is correct
53 Correct 35 ms 3416 KB Output is correct
54 Correct 35 ms 3420 KB Output is correct
55 Correct 35 ms 3588 KB Output is correct
56 Correct 35 ms 3416 KB Output is correct
57 Correct 35 ms 3420 KB Output is correct
58 Correct 35 ms 3416 KB Output is correct
59 Correct 36 ms 3420 KB Output is correct
60 Correct 35 ms 3416 KB Output is correct
61 Correct 35 ms 3604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 3420 KB Output is correct
2 Correct 1 ms 3420 KB Output is correct
3 Correct 1 ms 3420 KB Output is correct
4 Correct 1 ms 3420 KB Output is correct
5 Correct 1 ms 3420 KB Output is correct
6 Correct 1 ms 3420 KB Output is correct
7 Correct 1 ms 3420 KB Output is correct
8 Correct 1 ms 3420 KB Output is correct
9 Correct 35 ms 3416 KB Output is correct
10 Correct 35 ms 3420 KB Output is correct
11 Correct 36 ms 3420 KB Output is correct
12 Correct 35 ms 3420 KB Output is correct
13 Correct 35 ms 3416 KB Output is correct
14 Correct 35 ms 3420 KB Output is correct
15 Correct 35 ms 3420 KB Output is correct
16 Correct 37 ms 3420 KB Output is correct
17 Correct 35 ms 3416 KB Output is correct
18 Correct 35 ms 3416 KB Output is correct
19 Correct 35 ms 3420 KB Output is correct
20 Correct 35 ms 3416 KB Output is correct
21 Correct 35 ms 3416 KB Output is correct
22 Correct 37 ms 3420 KB Output is correct
23 Correct 37 ms 3420 KB Output is correct
24 Correct 45 ms 7256 KB Output is correct
25 Correct 47 ms 7256 KB Output is correct
26 Correct 46 ms 7260 KB Output is correct
27 Correct 1 ms 3420 KB Output is correct
28 Correct 1 ms 3420 KB Output is correct
29 Correct 1 ms 3420 KB Output is correct
30 Correct 20 ms 3564 KB Output is correct
31 Correct 23 ms 3420 KB Output is correct
32 Correct 18 ms 3580 KB Output is correct
33 Correct 25 ms 3420 KB Output is correct
34 Correct 34 ms 3420 KB Output is correct
35 Correct 31 ms 3420 KB Output is correct
36 Correct 29 ms 3420 KB Output is correct
37 Correct 31 ms 3420 KB Output is correct
38 Correct 21 ms 3420 KB Output is correct
39 Correct 26 ms 3604 KB Output is correct
40 Correct 23 ms 3608 KB Output is correct
41 Correct 22 ms 3420 KB Output is correct
42 Correct 21 ms 3420 KB Output is correct
43 Correct 20 ms 3416 KB Output is correct
44 Correct 25 ms 3420 KB Output is correct
45 Correct 30 ms 3420 KB Output is correct
46 Correct 22 ms 3592 KB Output is correct
47 Correct 35 ms 3420 KB Output is correct
48 Correct 35 ms 3420 KB Output is correct
49 Correct 35 ms 3416 KB Output is correct
50 Correct 45 ms 3420 KB Output is correct
51 Correct 34 ms 3416 KB Output is correct
52 Correct 35 ms 3420 KB Output is correct
53 Correct 38 ms 3420 KB Output is correct
54 Correct 35 ms 3420 KB Output is correct
55 Correct 35 ms 3416 KB Output is correct
56 Correct 35 ms 3416 KB Output is correct
57 Correct 35 ms 3420 KB Output is correct
58 Correct 35 ms 3588 KB Output is correct
59 Correct 35 ms 3416 KB Output is correct
60 Correct 35 ms 3420 KB Output is correct
61 Correct 35 ms 3416 KB Output is correct
62 Correct 36 ms 3420 KB Output is correct
63 Correct 35 ms 3416 KB Output is correct
64 Correct 35 ms 3604 KB Output is correct
65 Correct 19 ms 3420 KB Output is correct
66 Correct 34 ms 3584 KB Output is correct
67 Correct 35 ms 3416 KB Output is correct
68 Correct 35 ms 3420 KB Output is correct
69 Correct 32 ms 3420 KB Output is correct
70 Correct 33 ms 3676 KB Output is correct
71 Correct 31 ms 3676 KB Output is correct
72 Correct 28 ms 3752 KB Output is correct
73 Correct 27 ms 3676 KB Output is correct
74 Correct 25 ms 3676 KB Output is correct
75 Correct 25 ms 3672 KB Output is correct
76 Correct 33 ms 6236 KB Output is correct
77 Correct 36 ms 6488 KB Output is correct
78 Correct 45 ms 7000 KB Output is correct
79 Correct 35 ms 3420 KB Output is correct
80 Correct 35 ms 3672 KB Output is correct
81 Correct 35 ms 3420 KB Output is correct
82 Correct 36 ms 3604 KB Output is correct
83 Correct 35 ms 3420 KB Output is correct
84 Correct 36 ms 3672 KB Output is correct
85 Correct 36 ms 3676 KB Output is correct
86 Correct 36 ms 3676 KB Output is correct
87 Correct 38 ms 3676 KB Output is correct
88 Correct 36 ms 3672 KB Output is correct
89 Correct 36 ms 3672 KB Output is correct
90 Correct 51 ms 7300 KB Output is correct
91 Correct 51 ms 7260 KB Output is correct
92 Correct 51 ms 7256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 3420 KB Output is correct
2 Correct 1 ms 3420 KB Output is correct
3 Correct 1 ms 3420 KB Output is correct
4 Correct 1 ms 3420 KB Output is correct
5 Correct 1 ms 3420 KB Output is correct
6 Correct 1 ms 3420 KB Output is correct
7 Correct 1 ms 3420 KB Output is correct
8 Correct 1 ms 3420 KB Output is correct
9 Correct 35 ms 3416 KB Output is correct
10 Correct 35 ms 3420 KB Output is correct
11 Correct 36 ms 3420 KB Output is correct
12 Correct 35 ms 3420 KB Output is correct
13 Correct 35 ms 3416 KB Output is correct
14 Correct 35 ms 3420 KB Output is correct
15 Correct 35 ms 3420 KB Output is correct
16 Correct 37 ms 3420 KB Output is correct
17 Correct 35 ms 3416 KB Output is correct
18 Correct 35 ms 3416 KB Output is correct
19 Correct 35 ms 3420 KB Output is correct
20 Correct 35 ms 3416 KB Output is correct
21 Correct 35 ms 3416 KB Output is correct
22 Correct 37 ms 3420 KB Output is correct
23 Correct 37 ms 3420 KB Output is correct
24 Correct 45 ms 7256 KB Output is correct
25 Correct 47 ms 7256 KB Output is correct
26 Correct 46 ms 7260 KB Output is correct
27 Correct 1347 ms 3924 KB Output is correct
28 Correct 1327 ms 3700 KB Output is correct
29 Correct 1363 ms 3716 KB Output is correct
30 Correct 1340 ms 3676 KB Output is correct
31 Correct 1318 ms 3924 KB Output is correct
32 Correct 1363 ms 3672 KB Output is correct
33 Correct 1363 ms 4692 KB Output is correct
34 Correct 1315 ms 4688 KB Output is correct
35 Correct 1274 ms 4636 KB Output is correct
36 Correct 1385 ms 4688 KB Output is correct
37 Correct 1331 ms 4692 KB Output is correct
38 Correct 1479 ms 4628 KB Output is correct
39 Correct 1381 ms 7784 KB Output is correct
40 Correct 1369 ms 7768 KB Output is correct
41 Correct 1442 ms 7784 KB Output is correct
42 Correct 1 ms 3420 KB Output is correct
43 Correct 1 ms 3420 KB Output is correct
44 Correct 1 ms 3420 KB Output is correct
45 Correct 20 ms 3564 KB Output is correct
46 Correct 23 ms 3420 KB Output is correct
47 Correct 18 ms 3580 KB Output is correct
48 Correct 25 ms 3420 KB Output is correct
49 Correct 34 ms 3420 KB Output is correct
50 Correct 31 ms 3420 KB Output is correct
51 Correct 29 ms 3420 KB Output is correct
52 Correct 31 ms 3420 KB Output is correct
53 Correct 21 ms 3420 KB Output is correct
54 Correct 26 ms 3604 KB Output is correct
55 Correct 23 ms 3608 KB Output is correct
56 Correct 22 ms 3420 KB Output is correct
57 Correct 21 ms 3420 KB Output is correct
58 Correct 20 ms 3416 KB Output is correct
59 Correct 25 ms 3420 KB Output is correct
60 Correct 30 ms 3420 KB Output is correct
61 Correct 22 ms 3592 KB Output is correct
62 Correct 35 ms 3420 KB Output is correct
63 Correct 35 ms 3420 KB Output is correct
64 Correct 35 ms 3416 KB Output is correct
65 Correct 45 ms 3420 KB Output is correct
66 Correct 34 ms 3416 KB Output is correct
67 Correct 35 ms 3420 KB Output is correct
68 Correct 38 ms 3420 KB Output is correct
69 Correct 35 ms 3420 KB Output is correct
70 Correct 35 ms 3416 KB Output is correct
71 Correct 35 ms 3416 KB Output is correct
72 Correct 35 ms 3420 KB Output is correct
73 Correct 35 ms 3588 KB Output is correct
74 Correct 35 ms 3416 KB Output is correct
75 Correct 35 ms 3420 KB Output is correct
76 Correct 35 ms 3416 KB Output is correct
77 Correct 36 ms 3420 KB Output is correct
78 Correct 35 ms 3416 KB Output is correct
79 Correct 35 ms 3604 KB Output is correct
80 Correct 19 ms 3420 KB Output is correct
81 Correct 34 ms 3584 KB Output is correct
82 Correct 35 ms 3416 KB Output is correct
83 Correct 35 ms 3420 KB Output is correct
84 Correct 32 ms 3420 KB Output is correct
85 Correct 33 ms 3676 KB Output is correct
86 Correct 31 ms 3676 KB Output is correct
87 Correct 28 ms 3752 KB Output is correct
88 Correct 27 ms 3676 KB Output is correct
89 Correct 25 ms 3676 KB Output is correct
90 Correct 25 ms 3672 KB Output is correct
91 Correct 33 ms 6236 KB Output is correct
92 Correct 36 ms 6488 KB Output is correct
93 Correct 45 ms 7000 KB Output is correct
94 Correct 35 ms 3420 KB Output is correct
95 Correct 35 ms 3672 KB Output is correct
96 Correct 35 ms 3420 KB Output is correct
97 Correct 36 ms 3604 KB Output is correct
98 Correct 35 ms 3420 KB Output is correct
99 Correct 36 ms 3672 KB Output is correct
100 Correct 36 ms 3676 KB Output is correct
101 Correct 36 ms 3676 KB Output is correct
102 Correct 38 ms 3676 KB Output is correct
103 Correct 36 ms 3672 KB Output is correct
104 Correct 36 ms 3672 KB Output is correct
105 Correct 51 ms 7300 KB Output is correct
106 Correct 51 ms 7260 KB Output is correct
107 Correct 51 ms 7256 KB Output is correct
108 Correct 1322 ms 3716 KB Output is correct
109 Correct 947 ms 3672 KB Output is correct
110 Correct 813 ms 3676 KB Output is correct
111 Correct 751 ms 3728 KB Output is correct
112 Correct 1068 ms 3928 KB Output is correct
113 Correct 744 ms 3676 KB Output is correct
114 Correct 766 ms 4828 KB Output is correct
115 Correct 673 ms 4944 KB Output is correct
116 Correct 1167 ms 4892 KB Output is correct
117 Correct 710 ms 4772 KB Output is correct
118 Correct 851 ms 4948 KB Output is correct
119 Correct 908 ms 4584 KB Output is correct
120 Correct 765 ms 5976 KB Output is correct
121 Correct 824 ms 4128 KB Output is correct
122 Correct 855 ms 5976 KB Output is correct
123 Correct 744 ms 4260 KB Output is correct
124 Correct 1246 ms 6488 KB Output is correct
125 Correct 1266 ms 4228 KB Output is correct
126 Correct 1056 ms 4336 KB Output is correct
127 Correct 1279 ms 4552 KB Output is correct
128 Correct 898 ms 4188 KB Output is correct
129 Correct 966 ms 4188 KB Output is correct
130 Correct 1392 ms 3720 KB Output is correct
131 Correct 1399 ms 3920 KB Output is correct
132 Correct 1409 ms 3672 KB Output is correct
133 Correct 1359 ms 3824 KB Output is correct
134 Correct 1366 ms 3836 KB Output is correct
135 Correct 1391 ms 3676 KB Output is correct
136 Correct 1368 ms 5200 KB Output is correct
137 Correct 1375 ms 5124 KB Output is correct
138 Correct 1386 ms 5124 KB Output is correct
139 Correct 1361 ms 5204 KB Output is correct
140 Correct 1375 ms 5200 KB Output is correct
141 Correct 1296 ms 5128 KB Output is correct
142 Correct 1331 ms 7600 KB Output is correct
143 Correct 1324 ms 4420 KB Output is correct
144 Correct 1359 ms 7588 KB Output is correct
145 Correct 1358 ms 4396 KB Output is correct
146 Correct 1345 ms 7516 KB Output is correct
147 Correct 1353 ms 4404 KB Output is correct
148 Correct 1395 ms 4700 KB Output is correct
149 Correct 1294 ms 4444 KB Output is correct
150 Correct 1320 ms 4440 KB Output is correct
151 Correct 1409 ms 4612 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 3420 KB Output is correct
2 Correct 1 ms 3420 KB Output is correct
3 Correct 1 ms 3420 KB Output is correct
4 Correct 1 ms 3420 KB Output is correct
5 Correct 1 ms 3420 KB Output is correct
6 Correct 1 ms 3420 KB Output is correct
7 Correct 1 ms 3420 KB Output is correct
8 Correct 1 ms 3420 KB Output is correct
9 Correct 35 ms 3416 KB Output is correct
10 Correct 35 ms 3420 KB Output is correct
11 Correct 36 ms 3420 KB Output is correct
12 Correct 35 ms 3420 KB Output is correct
13 Correct 35 ms 3416 KB Output is correct
14 Correct 35 ms 3420 KB Output is correct
15 Correct 35 ms 3420 KB Output is correct
16 Correct 37 ms 3420 KB Output is correct
17 Correct 35 ms 3416 KB Output is correct
18 Correct 35 ms 3416 KB Output is correct
19 Correct 35 ms 3420 KB Output is correct
20 Correct 35 ms 3416 KB Output is correct
21 Correct 35 ms 3416 KB Output is correct
22 Correct 37 ms 3420 KB Output is correct
23 Correct 37 ms 3420 KB Output is correct
24 Correct 45 ms 7256 KB Output is correct
25 Correct 47 ms 7256 KB Output is correct
26 Correct 46 ms 7260 KB Output is correct
27 Correct 1347 ms 3924 KB Output is correct
28 Correct 1327 ms 3700 KB Output is correct
29 Correct 1363 ms 3716 KB Output is correct
30 Correct 1340 ms 3676 KB Output is correct
31 Correct 1318 ms 3924 KB Output is correct
32 Correct 1363 ms 3672 KB Output is correct
33 Correct 1363 ms 4692 KB Output is correct
34 Correct 1315 ms 4688 KB Output is correct
35 Correct 1274 ms 4636 KB Output is correct
36 Correct 1385 ms 4688 KB Output is correct
37 Correct 1331 ms 4692 KB Output is correct
38 Correct 1479 ms 4628 KB Output is correct
39 Correct 1381 ms 7784 KB Output is correct
40 Correct 1369 ms 7768 KB Output is correct
41 Correct 1442 ms 7784 KB Output is correct
42 Execution timed out 1558 ms 4288 KB Time limit exceeded
43 Halted 0 ms 0 KB -