#include <bits/stdc++.h>
#include "paint.h"
using namespace std;
#ifdef MIKU
string dbmc = "\033[1;38;2;57;197;187m", dbrs = "\033[0m";
#define debug(x...) cout << dbmc << "[" << #x << "]: ", dout(x)
void dout() { cout << dbrs << endl; }
template <typename T, typename ...U>
void dout(T t, U ...u) { cout << t << (sizeof...(u) ? ", " : ""); dout(u...); }
#else
#define debug(...) 39
#endif
#define fs first
#define sc second
#define mp make_pair
#define FOR(i, j, k) for (int i = j, Z = k; i < Z; i++)
using ll = long long;
typedef pair<int, int> pii;
namespace {
const int MXN = 200005, INF = 1e9;
int n, m, k;
vector<int> c;
vector<vector<int>> clr;
int cid[MXN], worker[MXN];
bitset<MXN> b;
int miku() {
fill(cid, cid + k, -1);
FOR(i, 0, m) {
for (auto &j : clr[i]) cid[j] = i;
}
FOR(i, 0, n) {
if (cid[c[i]] == -1) return -1;
worker[i] = cid[c[i]];
}
FOR(i, 1, n) if ((worker[i - 1] + 1) % m == worker[i]) b[i - 1] = true;
int ans = 0;
for (int i = 0, j = 0; i < n; i = ++j) {
while (j < n && b[j]) j++;
int x = j - i + 1;
if (x < m) return -1;
ans += (x - 1) / m + 1;
}
return ans;
}
}
int minimumInstructions(int N, int M, int K, vector<int> C, vector<int> A, vector<vector<int>> B) {
::n = N;
::m = M;
::k = K;
::c = C;
::clr = B;
return miku();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
440 KB |
Output is correct |
8 |
Correct |
1 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
600 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
860 KB |
Output is correct |
14 |
Correct |
1 ms |
860 KB |
Output is correct |
15 |
Correct |
1 ms |
860 KB |
Output is correct |
16 |
Correct |
1 ms |
856 KB |
Output is correct |
17 |
Correct |
1 ms |
856 KB |
Output is correct |
18 |
Correct |
1 ms |
860 KB |
Output is correct |
19 |
Correct |
1 ms |
708 KB |
Output is correct |
20 |
Correct |
1 ms |
860 KB |
Output is correct |
21 |
Correct |
1 ms |
860 KB |
Output is correct |
22 |
Correct |
8 ms |
2352 KB |
Output is correct |
23 |
Correct |
8 ms |
2396 KB |
Output is correct |
24 |
Correct |
11 ms |
2448 KB |
Output is correct |
25 |
Correct |
2 ms |
604 KB |
Output is correct |
26 |
Correct |
2 ms |
560 KB |
Output is correct |
27 |
Correct |
2 ms |
564 KB |
Output is correct |
28 |
Correct |
2 ms |
604 KB |
Output is correct |
29 |
Correct |
2 ms |
604 KB |
Output is correct |
30 |
Correct |
2 ms |
604 KB |
Output is correct |
31 |
Correct |
4 ms |
1656 KB |
Output is correct |
32 |
Correct |
4 ms |
1628 KB |
Output is correct |
33 |
Correct |
4 ms |
1648 KB |
Output is correct |
34 |
Correct |
4 ms |
1624 KB |
Output is correct |
35 |
Correct |
4 ms |
1628 KB |
Output is correct |
36 |
Correct |
4 ms |
1624 KB |
Output is correct |
37 |
Correct |
10 ms |
2912 KB |
Output is correct |
38 |
Correct |
10 ms |
2908 KB |
Output is correct |
39 |
Correct |
10 ms |
2904 KB |
Output is correct |
40 |
Correct |
7 ms |
1884 KB |
Output is correct |
41 |
Correct |
5 ms |
1220 KB |
Output is correct |
42 |
Correct |
8 ms |
2140 KB |
Output is correct |
43 |
Correct |
5 ms |
1372 KB |
Output is correct |
44 |
Correct |
5 ms |
1372 KB |
Output is correct |
45 |
Correct |
8 ms |
2136 KB |
Output is correct |
46 |
Correct |
25 ms |
11100 KB |
Output is correct |
47 |
Correct |
15 ms |
6488 KB |
Output is correct |
48 |
Correct |
21 ms |
10072 KB |
Output is correct |
49 |
Correct |
22 ms |
9168 KB |
Output is correct |
50 |
Correct |
23 ms |
8528 KB |
Output is correct |
51 |
Correct |
19 ms |
5980 KB |
Output is correct |
52 |
Correct |
10 ms |
2140 KB |
Output is correct |
53 |
Correct |
10 ms |
2140 KB |
Output is correct |
54 |
Correct |
8 ms |
2140 KB |
Output is correct |
55 |
Correct |
8 ms |
2140 KB |
Output is correct |
56 |
Correct |
9 ms |
2136 KB |
Output is correct |
57 |
Correct |
8 ms |
2140 KB |
Output is correct |
58 |
Correct |
28 ms |
12260 KB |
Output is correct |
59 |
Correct |
28 ms |
12116 KB |
Output is correct |
60 |
Correct |
28 ms |
12124 KB |
Output is correct |
61 |
Correct |
34 ms |
12252 KB |
Output is correct |
62 |
Correct |
28 ms |
12116 KB |
Output is correct |
63 |
Correct |
28 ms |
12228 KB |
Output is correct |
64 |
Correct |
27 ms |
11092 KB |
Output is correct |
65 |
Correct |
28 ms |
10908 KB |
Output is correct |
66 |
Correct |
28 ms |
11100 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
440 KB |
Output is correct |
8 |
Correct |
1 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
600 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
860 KB |
Output is correct |
14 |
Correct |
1 ms |
860 KB |
Output is correct |
15 |
Correct |
1 ms |
860 KB |
Output is correct |
16 |
Correct |
1 ms |
856 KB |
Output is correct |
17 |
Correct |
1 ms |
856 KB |
Output is correct |
18 |
Correct |
1 ms |
860 KB |
Output is correct |
19 |
Correct |
1 ms |
708 KB |
Output is correct |
20 |
Correct |
1 ms |
860 KB |
Output is correct |
21 |
Correct |
1 ms |
860 KB |
Output is correct |
22 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
23 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |