제출 #429854

#제출 시각아이디문제언어결과실행 시간메모리
429854Sundavar벽 칠하기 (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...