# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
567170 | Belgutei | 벽 칠하기 (APIO20_paint) | C++17 | 1574 ms | 13856 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "paint.h"
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define mk make_pair
#define X real()
#define Y imag()
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define MOD 1000000007
#define MOD1 1000000009
#define sqr(x) sqr((x)*(x))
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << ' ' << H; debug_out(T...); }
#ifdef BE_DEBUG
#define debug(...) cerr << "\033[1;31m(" << #__VA_ARGS__ << "):\033[0m", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
vector<int> v[100005];
int tur[100005];
int cnt[100005];
ll dp[100005];
int minimumInstructions( int N, int M, int K, std::vector<int> C, std::vector<int> A, std::vector<std::vector<int>> B) {
for(int i = 0; i < M; i ++) {
for(int j = 0; j < B[i].size(); j ++) {
// i-th person likes to paint color B[i][j]
v[B[i][j]].pb(i);
}
}
for(int i = 0; i < N; i ++) dp[i] = 1e9;
for(int i = 0; i < N; i ++) {
for(int j = 0; j < M; j ++){
tur[j] = cnt[j];
cnt[j] = 0;
}
bool check = 0;
for(auto x: v[C[i]]) {
int pre = x - 1;
if(pre == -1) pre = M - 1;
if(tur[pre] + 1 >= M) {
check = 1;
cnt[x] = M;
}
else {
cnt[x] = max(cnt[x], tur[pre] + 1);
}
}
if(check == 1) {
if(i == M - 1) {
dp[i] = 1;
}
for(int j = i - 1; j >= max(i - M,0); j --) {
dp[i] = min(dp[i], dp[j] + 1);
}
}
}
if(dp[N - 1] >= 1e9) return -1;
return dp[N - 1];
}
컴파일 시 표준 에러 (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... |