Submission #429854

#TimeUsernameProblemLanguageResultExecution timeMemory
429854SundavarPainting Walls (APIO20_paint)C++14
0 / 100
1 ms204 KiB
#include "paint.h" #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<vector<int> > colors(K); for(int i = 0; i < M; i++) for(int& a : B[i]) colors[a].push_back(i); int ans = 0, last = -3, l = M; for(int i = 0; i < N; i++){ if(colors[C[i]].empty()) return -1; if(colors[C[i]][0] != (last+1)%M){ if(l < M) return -1; ans++, l = 1; } else{ if(++l%M == 1) ans++; } } if(l < M) return -1; 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...