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 <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<bool> gd(n);
for (int i = 0; i <= n - m; i++){
for (int j = 0; j < m; j++){
bool ind = 1;
for (int k = 0; k < m; k++){
if (!f[(j + k) % m][x[i + k]]){
ind = 0;
break;
}
}
if (ind){
gd[i] = 1;
break;
}
}
}
int mx = -1, t = 0, 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;
}
# | 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... |