Submission #965828

#TimeUsernameProblemLanguageResultExecution timeMemory
965828pccPainting Walls (APIO20_paint)C++17
12 / 100
30 ms8884 KiB
#include "paint.h" #include <vector> #include <bits/stdc++.h> using namespace std; const int mxn = 1e5+10; #define pii pair<int,int> #define fs first #define sc second int col[mxn]; int minimumInstructions( int N, int M, int K, std::vector<int> C, std::vector<int> A, std::vector<std::vector<int>> B) { memset(col,-1,sizeof(col)); for(int i = 0;i<M;i++){ for(int j = 0;j<A[i];j++)col[B[i][j]] = i; } vector<pii> v; for(int i = 0;i<N;i++)C[i] = col[C[i]]; for(int i = 0;i<N;i++){ if(C[i]<0)return -1; if(v.empty()||(C[v.back().sc]+1)%M != C[i])v.push_back(pii(i,i)); else v.back().sc = i; } int ans = 0; for(auto &i:v){ if(i.sc-i.fs+1<M)return -1; ans += (i.sc-i.fs+1+M-1)/M; } return ans; }
#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...