#include "paint.h"
#pragma GCC optimize "O3,unroll-loops"
#pragma GCC target "abm,bmi,bmi2,popcnt,lzcnt,avx,avx2"
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define all(v) begin(v), end(v)
#define REP(i,o,n) for(int i=o;i<n;i++)
using namespace std;
int minimumInstructions(
int N, int M, int K, std::vector<int> C,
std::vector<int> A, std::vector<std::vector<int>> B) {
vector<pair<int,int>> vec;
map<int,int> like;
REP(i,0,M){
for(auto x:B[i])like[x]=i;
}
REP(i,0,N){
if(!like.count(C[i]))return -1;
int el=(i+M-like[C[i]])%M;
if(!vec.size() || vec.back().fi != el)vec.pb({el,1});
else vec.back().se++;
}
int ans=0;
for(auto i:vec){
if(i.se < M)return -1;
ans+=(i.se+M-1)/M;
}
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... |