# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
730684 | t6twotwo | Painting Walls (APIO20_paint) | C++17 | 1583 ms | 212 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "paint.h"
#include <bits/stdc++.h>
using namespace std;
constexpr int inf = 1E6;
int minimumInstructions(int N, int M, int K, vector<int> C, vector<int> A, vector<vector<int>> B) {
vector<vector<int>> f(K);
for (int i = 0; i < M; i++) {
for (int x : B[i]) {
f[x].push_back(i);
}
}
int good = 0;
vector<int> cnt(M);
auto add = [&](int x) {
for (int y : f[C[x]]) {
if (++cnt[((y - x) % M + M) % M] == M) {
good++;
}
}
};
auto rem = [&](int x) {
for (int y : f[C[x]]) {
if (cnt[((y - x) % M + M) % M]-- == M) {
good--;
}
}
};
for (int i = 0; i < M; i++) {
add(i);
}
vector<int> b;
for (int i = M; i <= N; i++) {
if (good) {
b.push_back(i - 1);
}
if (i == N) {
break;
}
rem(i - M);
add(i);
}
int ans = 0;
for (int i = -1, j = 0; i < N - 1; ans++) {
while (j + 1 < b.size() && b[j + 1] <= i + M) {
j++;
}
if (j == b.size() || b[j] > i + M) {
return -1;
}
i = b[j];
}
return ans;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |