제출 #319489

#제출 시각아이디문제언어결과실행 시간메모리
319489VEGAnn벽 칠하기 (APIO20_paint)C++14
28 / 100
1545 ms29284 KiB
#include "paint.h" #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define ft first using namespace std; using namespace __gnu_pbds; const int M = 50100; const int N = 100100; const int K = 100100; const int oo = 2e9; gp_hash_table<int, bool> inside[K]; int f[N]; // проверить, вдруг на большие ограничения залетит int minimumInstructions(int n, int m, int k, std::vector<int> C, std::vector<int> A, std::vector<std::vector<int>> B) { for (int i = 0; i < m; i++) for (int j = 0; j < A[i]; j++) inside[B[i][j]][i] = 1; f[n] = 0; fill(f, f + n, oo); for (int i = n - m; i >= 0; i--){ int mn = oo; for (int j = 1; j <= m; j++) mn = min(mn, f[i + j]); if (mn == oo) continue; for (auto cr : inside[C[i]]){ int now = cr.ft; bool ok = 1; for (int it = 1; it < m && ok; it++){ now++; if (now == m) now = 0; if (inside[C[i + it]].find(now) == inside[now].end()){ ok = 0; break; } } if (ok){ f[i] = mn + 1; break; } } } return (f[0] == oo ? -1 : f[0]); }
#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...