제출 #448499

#제출 시각아이디문제언어결과실행 시간메모리
448499nonsensenonsense1벽 칠하기 (APIO20_paint)C++17
100 / 100
1233 ms14264 KiB
#include "paint.h" const int N = 100000; const int M = 50000; int u[M], d[M]; std::vector<int> like[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) like[b[i][j]].push_back(i); int pre = -1, last = -1, amt = 1; for (int i = 0; i < n; ++i) { for (int j = 0; j < (int)like[c[i]].size(); ++j) { int cur = i - like[c[i]][j]; cur = (cur % m + m) % m; if (u[cur] != i) d[cur] = 0; ++d[cur]; u[cur] = i + 1; if (d[cur] >= m) { if (i - m > last) return -1; if (i - m <= pre) last = i; else { pre = last; last = i; ++amt; } } } } if (last < n - 1) return -1; return amt; }
#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...