# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
892760 | betterdanjoe | 벽 칠하기 (APIO20_paint) | C++17 | 56 ms | 23600 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#ifndef LOCAL
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx,avx2,fma")
#endif
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ff first
#define ss second
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;
const int INF = 1e9;
const ll LLINF = 1e18;
const int MOD = 1e9 + 7;
int minimumInstructions(int N, int M, int K, vector<int> C, vector<int> A, vector<vector<int>> B) {
vector<int> pos[K];
for(int i = 0; i < N; i++){
pos[C[i]].pb(i);
}
vector<int> val[N];
vector<int> len[N];
for(int i = 0; i < M; i++){
for(int j : B[i]){
for(int k : pos[j]){
val[k].pb(i);
}
}
}
for(int i = 0; i < N; i++) len[i].resize(val[i].size(), 0);
for(int i = N - 1; i >= 1; i--){
int ind = 0;
for(int j = 0; j < val[i].size(); j++){
while(ind < val[i - 1].size() && val[i - 1][ind] < val[i][j] - 1) ind++;
if(ind < val[i - 1].size() && val[i - 1][ind] == val[i][j] - 1){
len[i - 1][ind] = len[i][j] + 1;
}
}
}
bool check[N];
memset(check, false, sizeof(check));
for(int i = 0; i < N - M + 1; i++){
for(int j = 0; j < val[i].size(); j++){
if(len[i][j] == M - 1){
check[i] = true;
break;
}
if(len[i][j] == M - 1 - val[i][j] && val[i + len[i][j] + 1][0] == 0 && len[i + len[i][j] + 1][0] >= val[i][j] - 1){
check[i] = true;
break;
}
}
}
int cur = 0;
int prv = 0;
int ans = 0;
while(cur < N){
int nxt = -1;
for(int i = prv; i <= cur; i++){
if(check[i]) nxt = i + M;
}
if(nxt == -1) return -1;
ans++;
prv = cur + 1;
cur = nxt;
}
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... |