#include "paint.h"
#include <vector>
#include <bitset>
using namespace std;
const int MAXN = 501;
const int MAXM = 201;
bitset<MAXM> goodseg[MAXN];
bitset<MAXM> rgoodcl[MAXN];
bool get_good_seg(int n, int m, int k, vector<int>& cl, vector<vector<int>>& goodcl, int l) {
if (l > n - m)
return false;
return goodseg[l].count();
}
int minimumInstructions(int n, int m, int k, vector<int> cl, vector<int> a, vector<vector<int>> goodcl) {
for (int i = 0; i < n; ++i) {
--cl[i];
for (int j = 0; j < m; ++j)
goodseg[i][j] = 1;
}
for (int i = 0; i < m; ++i) {
for (auto ccl : goodcl[i])
rgoodcl[ccl][i] = 1;
}
for (int i = 0; i < n; ++i) {
bitset<MAXM> curgoodcl = rgoodcl[cl[i]];
for (int j = i; j >= 0 && j > i - m; --j) {
goodseg[j] &= curgoodcl;
curgoodcl[m] = curgoodcl[0];
curgoodcl = curgoodcl >> 1;
}
}
int endcvr = 0;
int maxcvr = 0;
int ans = 0;
for (int i = 0; i < n; ++i) {
if (get_good_seg(n, m, k, cl, goodcl, i))
maxcvr = i + m;
if (i >= endcvr) {
endcvr = maxcvr;
++ans;
}
if (i >= endcvr)
return -1;
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |