# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
576655 | pnm1384 | Painting Walls (APIO20_paint) | C++14 | 764 ms | 18656 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "paint.h"
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
const int N = 3e5 + 20;
vector<int> vt[N];
int col[N], last[N], dp[N];
bool have[N];
vector<pair<int, int>> vt1, vt2;
int minimumInstructions(int N, int M, int K, std::vector<int> C, std::vector<int> A, std::vector<std::vector<int>> B)
{
int n = N, m = M, k = K;
for (int i = 0; i < n; i++)
{
col[i] = C[i];
}
for (int i = 0; i < m; i++)
{
for (int j = 0; j < A[i]; j++)
{
int c = B[i][j];
vt[c].push_back(i);
}
}
for (int i = 0; i < m; i++)
{
last[i] = -2;
dp[i] = -2;
}
for (int i = 0; i < n; i++)
{
vt1.clear(); vt2.clear();
for (int j : vt[col[i]])
{
int j2 = j - 1;
if (j2 < 0) j2 = m - 1;
if (last[j2] == i - 1)
{
vt1.push_back({j, min(dp[j2] + 1, m)});
}
else
{
vt2.push_back({j, 1});
}
}
for (pair<int, int> pppp : vt1)
{
int j = pppp.F;
dp[j] = pppp.S;
assert(dp[j] <= i + 1);
last[j] = i;
}
for (pair<int, int> pppp : vt2)
{
int j = pppp.F;
dp[j] = 1;
last[j] = i;
}
for (int j : vt[col[i]])
{
if (dp[j] == m)
{
have[i - m + 1] = true;
//assert(i - m + 1 >= 0);
}
}
}
int i = 0, j = 0;
int ans = 0;
while (i < n)
{
int ff = -1;
for (int kk = i; kk >= j; kk--)
{
if (have[kk])
{
ff = kk;
break;
}
}
if (ff == -1) return -1;
ans++;
j = i + 1;
i = m + ff;
}
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... |