#include "paint.h"
#include <bits/stdc++.h>
using namespace std;
const int maxn = 510, maxk = 1e5 + 10;
int dp[maxn], c[maxn], a[maxn], n, m;
vector < int > b[maxn];
bitset < maxn > col[maxk];
int minimumInstructions(
int N, int M, int K, vector<int> C,
vector<int> A, vector<vector<int>> B)
{
n = N;
m = M;
for (int i = 0; i < n; i ++)
{
c[i] = C[i];
}
for (int i = 0; i < m; i ++)
{
a[i] = A[i];
for (int j = 0; j < a[i]; j ++)
b[i].push_back(B[i][j]), col[b[i][j]][i] = 1;
}
for (int i = 0; i < N; i ++)
dp[i] = 1e9;
for (int i = N - M; i >= 0; i --)
{
bool tf = false;
for (int st = 0; st < M; st ++)
{
bool pos = true;
for (int pos = 0; pos < M; pos ++)
{
if (col[c[i + pos]][(st + pos) % M] == 0)
{
pos = false;
break;
}
}
if (pos)
{
tf = true;
break;
}
}
if (tf)
{
for (int j = i + 1; j <= i + M; j ++)
dp[i] = min(dp[i], dp[j] + 1);
}
}
if (dp[0] > N)
return -1;
return dp[0];
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |