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>
#define pb push_back
#define f first
#define sc second
using namespace std;
typedef long long int ll;
typedef string str;
int minimumInstructions(int n, int m, int K, vector<int> C, vector<int> A, vector<vector<int>> B){
vector<unordered_set<int>> likes(m);
for(int i = 0; i < m; i++) for(int x: B[i]) likes[i].insert(x);
vector<bool> p(n, 0);
for(int i = n-m; i >= 0; i--){
for(int j = 0; j < m; j++){
bool ok = 1;
for(int k = 0; k < m; k++) if(likes[(j+k)%m].find(C[i+k]) == likes[(j+k)%m].end())
ok = 0;
p[i] = p[i]|ok;
}
}
int ans = 0, ls = -1, c = 0;
for(int i = n-1; i >= 0; i--){
c++;
if(p[i]) ls = i;
if(c == m || i == 0){
if(ls == -1) return -1;
ans++;
c=ls-i;
ls = -1;
}
}
return ans;
}
# | 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... |