# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
730684 | 2023-04-26T09:11:55 Z | t6twotwo | 벽 칠하기 (APIO20_paint) | C++17 | 1500 ms | 212 KB |
#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; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Execution timed out | 1583 ms | 212 KB | Time limit exceeded |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Execution timed out | 1583 ms | 212 KB | Time limit exceeded |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Execution timed out | 1583 ms | 212 KB | Time limit exceeded |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Execution timed out | 1583 ms | 212 KB | Time limit exceeded |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Execution timed out | 1583 ms | 212 KB | Time limit exceeded |
4 | Halted | 0 ms | 0 KB | - |