# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1225989 | sokratisi | 벽 칠하기 (APIO20_paint) | C++20 | 0 ms | 0 KiB |
#include "paint.h"
#include <vector>
#include <set>
using namespace std;
set<int> coltoconst[100005];
int minimumInstructions(int n, int m, int k, vector<int> c, vector<int> a, vector<vector<int>> b) {
for (int i = 0; i < m; i++) {
for (int j = 0; j < a[i]; j++) coltoconst[b[i][j]].insert(i);
}
int init = 0;
int ans = 0;
bool okay = true;
set<int> cur;
cur = coltoconst[0];
for (int i = 1; i < n; i++) {
for (auto u: cur) if (coltoconst[i].find((u+i)%M) == coltoconst.end()) cur.erase(u);
if (cur.empty()) {
if (i - init < k) okay = false;
ans += (i-init-1)/k + 1;
init = i;
cur = coltoconst[i];
}
}
return ans;
}