## Submission #347978

# Submission time Handle Problem Language Result Execution time Memory
347978 2021-01-14T01:33:38 Z arnold518 Painting Walls (APIO20_paint) C++14
0 / 100
3 ms 4716 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 = 2e4;
const int MAXM = 2000;
const int MAXK = 1e5;

int N, M, K;
int C[MAXN+10];
vector<int> B[MAXK+10];

int dp[MAXN+10][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][it]=1;
if(i!=0 && dp[i-1][(it+M-1)%M])
{
dp[i][it]=dp[i-1][(it+M-1)%M]+1;
}
if(dp[i][it]>=M)
{
chk[i+1]=1;
}
}
}
/*
for(int i=0; i<M; i++)
{
for(int j=0; j<N; j++)
{
printf("%d ", dp[j][i]);
}
printf("\n");
}

*/	deque<int> DQ;
DQ.push_back(0);
for(int i=1; i<=N; i++)
{
dp2[i]=987654321;
while(!DQ.empty() && DQ.front()<i-M) DQ.pop_front();
if(chk[i] && !DQ.empty())
{
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];
}```

#### Subtask #1 0 / 12.0

# Verdict Execution time Memory Grader output
1 Correct 3 ms 2804 KB Output is correct
2 Correct 2 ms 2668 KB Output is correct
3 Correct 2 ms 2668 KB Output is correct
4 Correct 3 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 3 ms 4716 KB Output is correct
8 Correct 3 ms 4716 KB Output is correct
9 Incorrect 3 ms 4716 KB Output isn't correct
10 Halted 0 ms 0 KB -

#### Subtask #2 0 / 15.0

# Verdict Execution time Memory Grader output
1 Correct 2 ms 2668 KB Output is correct
2 Correct 2 ms 2668 KB Output is correct
3 Correct 3 ms 2804 KB Output is correct
4 Correct 2 ms 2668 KB Output is correct
5 Correct 2 ms 2668 KB Output is correct
6 Correct 3 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 3 ms 4716 KB Output is correct
10 Correct 3 ms 4716 KB Output is correct
11 Incorrect 3 ms 4716 KB Output isn't correct
12 Halted 0 ms 0 KB -

#### Subtask #3 0 / 13.0

# Verdict Execution time Memory Grader output
1 Correct 2 ms 2668 KB Output is correct
2 Correct 2 ms 2668 KB Output is correct
3 Correct 3 ms 2804 KB Output is correct
4 Correct 2 ms 2668 KB Output is correct
5 Correct 2 ms 2668 KB Output is correct
6 Correct 3 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 3 ms 4716 KB Output is correct
10 Correct 3 ms 4716 KB Output is correct
11 Incorrect 3 ms 4716 KB Output isn't correct
12 Halted 0 ms 0 KB -

#### Subtask #4 0 / 23.0

# Verdict Execution time Memory Grader output
1 Correct 2 ms 2668 KB Output is correct
2 Correct 2 ms 2668 KB Output is correct
3 Correct 3 ms 2804 KB Output is correct
4 Correct 2 ms 2668 KB Output is correct
5 Correct 2 ms 2668 KB Output is correct
6 Correct 3 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 3 ms 4716 KB Output is correct
10 Correct 3 ms 4716 KB Output is correct
11 Incorrect 3 ms 4716 KB Output isn't correct
12 Halted 0 ms 0 KB -

#### Subtask #5 0 / 37.0

# Verdict Execution time Memory Grader output
1 Correct 2 ms 2668 KB Output is correct
2 Correct 2 ms 2668 KB Output is correct
3 Correct 3 ms 2804 KB Output is correct
4 Correct 2 ms 2668 KB Output is correct
5 Correct 2 ms 2668 KB Output is correct
6 Correct 3 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 3 ms 4716 KB Output is correct
10 Correct 3 ms 4716 KB Output is correct
11 Incorrect 3 ms 4716 KB Output isn't correct
12 Halted 0 ms 0 KB -