Submission #409651

#TimeUsernameProblemLanguageResultExecution timeMemory
409651enerelt14Painting Walls (APIO20_paint)C++14
0 / 100
10 ms20300 KiB
#include "paint.h" #include<bits/stdc++.h> #include <vector> bool is[205][100005]; int minimumInstructions( int N, int M, int K, std::vector<int> C, std::vector<int> A, std::vector<std::vector<int>> B) { bool ps[505]; memset(ps, 0, sizeof(ps)); memset(is, 0, sizeof(is)); for (int i=0;i<M;i++)for (int j=0;j<A[i];j++)is[i][B[i][j]]=1; for (int i=0;i<N-M;i++){ for (int j=0;j<M;j++){ if (ps[i])break; if (is[j][C[i]]){ bool x=0; for (int l=0;l<M;l++){ if (!is[(j+l)%M][C[i+l]]){ x=1; break; } } if (!x)ps[i]=1; } } } int res=1, t=N-M; if (!ps[t])return -1; while(t!=0){ bool q=0; for (int i=t-M;i<t;i++){ if (ps[i]){ t=i; q=1; res++; break; } } if (!q)return -1; } return res; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...