Submission #735380

#TimeUsernameProblemLanguageResultExecution timeMemory
735380keisuke6Painting Walls (APIO20_paint)C++14
0 / 100
0 ms212 KiB
#include "paint.h" #include <iostream> #include <vector> #include <map> using namespace std; int minimumInstructions(int N, int M, int K, vector<int> C,vector<int> A, vector<vector<int>> B){ map<int,int> m;// c, p vector<int> AA(N); for(int i=0;i<M;i++){ for(int x:B[i]){ m[x] = i; } } for(int i=0;i<N;i++){ if(!m.count(C[i])) return -1; AA[i] = m[C[i]]; } int ans = 1, l = 0; for(int i=1;i<N;i++){ if((AA[i-1]+1)%M != AA[i] || A[l] == A[i]){ ans++; l = i; if(N-M < i) 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...