# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
737710 | Abrar_Al_Samit | 벽 칠하기 (APIO20_paint) | C++17 | 1608 ms | 409456 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "paint.h"
#include <bits/stdc++.h>
using namespace std;
const int nax = 1e5 + 1;
vector<int> col_to_wall[nax], cand[nax];
bool good[nax];
int minimumInstructions(
int N, int M, int K, vector<int> C,
vector<int> A, vector<vector<int>> B) {
for(int i=0; i<N; ++i) {
col_to_wall[C[i]].push_back(i);
}
for(int i=0; i<M; ++i) {
for(int j=0; j<A[i]; ++j) {
for(int x : col_to_wall[B[i][j]]) {
cand[x].push_back(i);
}
}
}
for(int i=0; i<K; ++i) {
col_to_wall[i].clear();
}
vector<int>dp(cand[N-1].size());
for(int i=N-1; i>=1; --i) {
vector<int>new_dp(cand[i-1].size());
int ptr = 0;
for(int j=0; j<cand[i-1].size(); ++j) {
if(cand[i-1][j]+1==M) {
if(!cand[i].empty() && cand[i][0]==0) {
new_dp[j] = 1 + dp[0];
}
continue;
}
while(ptr+1<cand[i].size() && cand[i][ptr+1]<=cand[i-1][j]+1) {
++ptr;
}
if(!cand[i].empty() && cand[i][ptr]==cand[i-1][j]+1) {
new_dp[j] = 1 + dp[ptr];
}
}
if(i-1<=N-M) {
for(int j=0; j<cand[i-1].size(); ++j) {
int cur = 1 + new_dp[j];
if(cur>=M) good[i-1] = 1;
}
}
dp.swap(new_dp);
}
if(M==1 && !cand[N-1].empty()) good[N-1] = 1;
if(!good[0]) return -1;
int last = 0, pending = -1;
int ans = 1;
for(int i=1; i<N; ++i) {
if(good[i]) {
pending = i;
}
if(last+M==i) {
if(pending==-1) return -1;
last = pending;
pending = -1;
++ans;
}
}
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... |