제출 #500916

#제출 시각아이디문제언어결과실행 시간메모리
500916sidon벽 칠하기 (APIO20_paint)C++17
12 / 100
57 ms14488 KiB
#include <bits/stdc++.h> using namespace std; #define V vector int minimumInstructions(int N, int M, int K, V<int> C, V<int> A, V<V<int>> B) { int ans = 0; V<int> cand[K], x(M), y(M), dp(N+1); dp[N] = 1; for(int i = 0; i < M; i++) for(int &j : B[i]) cand[j].push_back(i); for(int i = N; --i >= 0; swap(x, y)) { if(i+2 < N) for(int j : cand[C[i+2]]) x[j] = 0; for(int j : cand[C[i]]) if((x[j] = 1 + y[(j + 1) % M]) >= M) dp[i] = 1; } for(int i = 0, j; i < N; i=j, ans++) { j = min(N, i + M); while(j > i && !dp[j]) --j; if(i == j) 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...