#include "paint.h"
#include <cstring>
#include <vector>
const int K = 100000;
int minimumInstructions(int n, int m, int k, std::vector<int> aa, std::vector<int> kk, std::vector<std::vector<int>> aaa) {
static int jj[K];
int h, i, i_, j, ans;
memset(jj, -1, m * sizeof *jj);
for (j = 0; j < m; j++)
for (h = 0; h < kk[j]; h++)
jj[aaa[j][h]] = j;
for (i = 0; i < n; i++)
if (jj[aa[i]] == -1)
return 0;
ans = 0;
for (i = 0; i < n; i = i_) {
i_ = i + 1;
while (i_ < n && (jj[aa[i_ - 1]] + 1) % m == jj[aa[i_]])
i_++;
if (i_ - i < m)
return -1;
ans += (i_ - i + m - 1) / m;
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |