Submission #433472

#TimeUsernameProblemLanguageResultExecution timeMemory
433472cgiosyPainting Walls (APIO20_paint)C++17
100 / 100
460 ms14620 KiB
#include <bits/stdc++.h> using namespace std; int minimumInstructions(int N, int M, int K, vector<int> C, vector<int> A, vector<vector<int>> B) { vector<int> G[K]; for(int i=0; i<M; i++) for(int j:B[i]) G[j].push_back(i); int X[M][2]{}, cnt=0, pr=-1e9, r=-1; for(int i=0; i<N; i++) { bool ok=0; for(int j:G[C[i]]) ok|=(X[j][i&1]=X[(j ?: M)-1][~i&1]+1)>=M; if(i) for(int j:G[C[i-1]]) X[j][~i&1]=0; if(ok && i-r<=M) { if(i-pr>M) pr=r, cnt++; r=i; } } return r==N-1 ? cnt : -1; }
#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...