제출 #1203151

#제출 시각아이디문제언어결과실행 시간메모리
1203151O_ElmasryPainting Walls (APIO20_paint)C++20
0 / 100
0 ms528 KiB
#include "paint.h" #include<bits/stdc++.h> using namespace std; #include <vector> using ll = long long; const ll INF = 1e9; int minimumInstructions(int N, int M, int K, vector<int> C, vector<int> A, vector<vector<int>> B) { vector<ll>dp(N, INF); vector<vector<int>>comp(M, vector<int>(N)); for(int i = 0;i < M;i++){ for(int j = 0;j < N;j++){ if(binary_search(B[i].begin(), B[i].end(), C[j]))comp[i][j] = 1; } } auto check = [&](int x, int y){ bool ok = 1; for(int i = 0;i < M;i++){ int xx = (x + i) % M; int yy = y + i; ok &= comp[xx][yy]; } return ok; }; for(int i = M - 1;i < N;i++){ for(int j = 0;j < M;j++){ bool ok = check(j, i - M + 1); if(!ok)continue; if(i == M - 1){ dp[i] = 1; } for(int k = max(0, i - M);k < i;k++){ dp[i] = min(dp[i], dp[k] + 1); // cout << i << " " << k << " " << j << " " << dp[i] << endl; } } } return dp[N - 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...