# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
414196 | prvocislo | 벽 칠하기 (APIO20_paint) | C++17 | 993 ms | 524292 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <vector>
using namespace std;
int minimumInstructions(int n, int m, int k, vector<int> c, vector<int> a, vector<vector<int>> b) {
vector<vector<int> > f(k); // ktorym kontraktorom sa paci tato farba
for (int i = 0; i < m; i++) for (int j : b[i]) f[j].push_back(i), f[j].push_back(i + m);
const int off = n + 5, maxi = 2 * m + n + 10;
vector<vector<int> > s(maxi); // ktore indexy maju toto cislo
for (int i = 0; i < n;i++)
{
for (int j : f[c[i]]) s[off + j - i].push_back(i);
}
vector<int> st(n, 0); // mozeme na tomto indexe zacat
for (int i = 0; i < maxi; i++)
{
if (s[i].empty()) continue;
int miss = s[i][0]-1; // posledne ktore nam chyba
for (int j = 0; j < s[i].size(); j++)
{
if (j && s[i][j - 1] != s[i][j] - 1) miss = s[i][j] - 1;
if (miss + m <= s[i][j])
st[s[i][j] - (m - 1)] = 1;
}
}
int last = -1; // posledne zafarbene
int best = -1e9; // najlepsie ktore mozeme zobrat
int ans = 0;
for (int i = 0; i < n; i++)
{
if (st[i]) best = i;
if (last < i)
{
if (best + m - 1 < i)
return -1;
ans ++;
last = best + m - 1;
}
}
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... |