Submission #949379

#TimeUsernameProblemLanguageResultExecution timeMemory
949379vjudge1Painting Walls (APIO20_paint)C++17
0 / 100
1 ms348 KiB
#include "paint.h" #include <bits/stdc++.h> using namespace std; #define size(x) (int)x.size() #define all(x) x.begin(), x.end() template<class S, class T> bool chmin(S& a, const T& b) { return a > b ? (a = b) == b : false; } template<class S, class T> bool chmax(S& a, const T& b) { return a < b ? (a = b) == b : false; } const int inf = 1e9; int minimumInstructions(int n, int m, int K, vector<int> c, vector<int> a, vector<vector<int>> b) { vector<int> dp(n, inf); vector<map<int, bool>> mp(m); for (int i = 0; i < m; ++i) { for (auto x : b[i]) { mp[i][x] = true; } } for (int i = 0; i + m - 1 < n; ++i) { for (int k = 0; k < m; ++k) { int r = i; bool flag = true; for (int j = k; j < m; ++j) { if (!mp[j][c[r]]) { flag = false; break; } r++; } if (flag) { for (int j = 0; j < k; ++j) { if (!mp[j][c[r]]) break; r++; } } for (int j = i; j < r; ++j) { if (i) chmin(dp[j], dp[i - 1] + 1); else chmin(dp[j], 1); } } } return dp[n - 1] == inf ? -1 : 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...