Submission #965826

#TimeUsernameProblemLanguageResultExecution timeMemory
965826pccPainting Walls (APIO20_paint)C++17
0 / 100
1 ms348 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) { 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(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...