# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
898296 | irmuun | Painting Walls (APIO20_paint) | C++17 | 1593 ms | 25356 KiB |
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>
//#include "paint.h"
using namespace std;
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define all(s) s.begin(),s.end()
#define rall(s) s.rbegin(),s.rend()
int minimumInstructions(int n,int m,int k,vector<int>C,vector<int>A,vector<vector<int>>B){
vector<vector<bool>>can(m,vector<bool>(k,false));
for(int i=0;i<m;i++){
for(int j=0;j<A[i];j++){
can[i][B[i][j]]=true;
}
}
vector<bool>canStart(n,0);
int cur;
for(int i=0;i<=n-m;i++){
bool flag=false;
for(int s=0;s<m;s++){
bool now=true;
for(int y=0;y<m;y++){
now&=(can[(s+y)%m][C[i+y]]);
}
flag|=now;
}
if(flag){
canStart[i]=true;
}
}
int ans=0;
bool ok=true;
if(!canStart[0]) return -1;
ans++;
int r=m-1,nxt=0;
for(int i=1;i<n;i++){
if(canStart[i]){
nxt=i;
}
if(i>r){
r=nxt+m-1;
if(i>r) return -1;
ans++;
}
}
return ans;
}
Compilation message (stderr)
# | 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... |