This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "paint.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long un;
typedef vector<un> vuc;
typedef vector<bool> vol;
#define vec vector
#define REP(i, a, b) for (un i = (un)a; i < (un)b; i++)
#define FEAC(i, a) for (auto&& i : a)
constexpr un INF = 1e9;
int minimumInstructions(int N, int M, int K, std::vector<int> C, std::vector<int> A, std::vector<std::vector<int>> B) {
vec<vol> tab(M, vol(K, false));
REP(m, 0, M) {
FEAC(col, B[m]) tab[m][col] = true;
}
un ret = 0;
un x = 0;
while (x < N)
{
un nejkdy = 0;
REP(y, 0, M){
bool bad = false;
bool skoc = false;
un kdy = M;
REP(l, 0, M){
if ((x+l - skoc*M < 0) or (x+l - skoc*M >= N) or (not tab[(y+l)%M][C[x+l - skoc*M]])){
if (not skoc) {
kdy = l;
l--;
skoc = true;
}
else{
bad = true;
break;
}
}
}
if(not bad){
nejkdy = max(nejkdy, kdy);
}
}
if (nejkdy == 0){
return -1;
}
x += nejkdy;
ret++;
}
return ret;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |