# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
347984 | 2021-01-14T01:44:38 Z | arnold518 | 벽 칠하기 (APIO20_paint) | C++14 | 3 ms | 2668 KB |
#include "paint.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int MAXN = 1e5; const int MAXM = 5e4; const int MAXK = 1e5; int N, M, K; int C[MAXN+10]; vector<int> B[MAXK+10]; int dp[2][MAXM+10], chk[MAXN+10]; int dp2[MAXN+10]; int minimumInstructions(int _N, int _M, int _K, vector<int> _C, vector<int> _A, vector<vector<int>> _B) { N=_N; M=_M; K=_K; for(int i=0; i<N; i++) C[i]=_C[i]; for(int i=0; i<M; i++) { for(auto it : _B[i]) { B[it].push_back(i); } } for(int i=0; i<N; i++) { for(auto it : B[C[i]]) { dp[i&1][it]=1; if(i!=0 && dp[i-1&1][(it+M-1)%M]) { dp[i&1][it]=dp[i-1&1][(it+M-1)%M]+1; } if(dp[i&1][it]>=M) { chk[i+1]=1; } } } deque<int> DQ; DQ.push_back(0); for(int i=1; i<=N; i++) { dp2[i]=987654321; if(!chk[i]) continue; while(!DQ.empty() && DQ.front()<i-M) DQ.pop_front(); if(DQ.empty()) continue; dp2[i]=dp2[DQ.front()]+1; while(!DQ.empty() && dp2[DQ.back()]>=dp2[i]) DQ.pop_back(); DQ.push_back(i); //printf("%d ", dp2[i]); } if(dp2[N]==987654321) return -1; return dp2[N]; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 2668 KB | Output is correct |
2 | Correct | 2 ms | 2668 KB | Output is correct |
3 | Correct | 2 ms | 2668 KB | Output is correct |
4 | Correct | 2 ms | 2668 KB | Output is correct |
5 | Correct | 2 ms | 2668 KB | Output is correct |
6 | Correct | 2 ms | 2668 KB | Output is correct |
7 | Correct | 2 ms | 2668 KB | Output is correct |
8 | Correct | 2 ms | 2668 KB | Output is correct |
9 | Incorrect | 2 ms | 2668 KB | Output isn't correct |
10 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 2668 KB | Output is correct |
2 | Correct | 2 ms | 2668 KB | Output is correct |
3 | Correct | 3 ms | 2668 KB | Output is correct |
4 | Correct | 2 ms | 2668 KB | Output is correct |
5 | Correct | 2 ms | 2668 KB | Output is correct |
6 | Correct | 2 ms | 2668 KB | Output is correct |
7 | Correct | 2 ms | 2668 KB | Output is correct |
8 | Correct | 2 ms | 2668 KB | Output is correct |
9 | Correct | 2 ms | 2668 KB | Output is correct |
10 | Correct | 2 ms | 2668 KB | Output is correct |
11 | Incorrect | 2 ms | 2668 KB | Output isn't correct |
12 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 2668 KB | Output is correct |
2 | Correct | 2 ms | 2668 KB | Output is correct |
3 | Correct | 3 ms | 2668 KB | Output is correct |
4 | Correct | 2 ms | 2668 KB | Output is correct |
5 | Correct | 2 ms | 2668 KB | Output is correct |
6 | Correct | 2 ms | 2668 KB | Output is correct |
7 | Correct | 2 ms | 2668 KB | Output is correct |
8 | Correct | 2 ms | 2668 KB | Output is correct |
9 | Correct | 2 ms | 2668 KB | Output is correct |
10 | Correct | 2 ms | 2668 KB | Output is correct |
11 | Incorrect | 2 ms | 2668 KB | Output isn't correct |
12 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 2668 KB | Output is correct |
2 | Correct | 2 ms | 2668 KB | Output is correct |
3 | Correct | 3 ms | 2668 KB | Output is correct |
4 | Correct | 2 ms | 2668 KB | Output is correct |
5 | Correct | 2 ms | 2668 KB | Output is correct |
6 | Correct | 2 ms | 2668 KB | Output is correct |
7 | Correct | 2 ms | 2668 KB | Output is correct |
8 | Correct | 2 ms | 2668 KB | Output is correct |
9 | Correct | 2 ms | 2668 KB | Output is correct |
10 | Correct | 2 ms | 2668 KB | Output is correct |
11 | Incorrect | 2 ms | 2668 KB | Output isn't correct |
12 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 2668 KB | Output is correct |
2 | Correct | 2 ms | 2668 KB | Output is correct |
3 | Correct | 3 ms | 2668 KB | Output is correct |
4 | Correct | 2 ms | 2668 KB | Output is correct |
5 | Correct | 2 ms | 2668 KB | Output is correct |
6 | Correct | 2 ms | 2668 KB | Output is correct |
7 | Correct | 2 ms | 2668 KB | Output is correct |
8 | Correct | 2 ms | 2668 KB | Output is correct |
9 | Correct | 2 ms | 2668 KB | Output is correct |
10 | Correct | 2 ms | 2668 KB | Output is correct |
11 | Incorrect | 2 ms | 2668 KB | Output isn't correct |
12 | Halted | 0 ms | 0 KB | - |