#include "paint.h"
#include <bits/stdc++.h>
using namespace std;
#define size(x) (int)x.size()
#define all(x) x.begin(), x.end()
template<class S, class T> bool chmin(S& a, const T& b) {
return a > b ? (a = b) == b : false;
}
template<class S, class T> bool chmax(S& a, const T& b) {
return a < b ? (a = b) == b : false;
}
const int inf = 1e9;
int minimumInstructions(int n, int m, int K,
vector<int> c, vector<int> a, vector<vector<int>> B) {
if (n % m) return -1;
deque<vector<int>> b(m);
for (int i = 0; i < m; ++i) {
b[i].resize(a[i]);
for (int j = 0; j < a[i]; ++j) {
b[i][j] = B[i][j];
}
}
int k = -1;
for (int i = 0; i < m; ++i) {
if (binary_search(all(b[i]), c[0])) {
k = i;
break;
}
}
if (k == -1) return -1;
while (k--) {
b.push_back(b.front());
b.pop_front();
}
for (int i = 0; i < n; i += m) {
for (int j = 0; j < m; ++j) {
if (!binary_search(all(b[j]), c[i + j])) {
return -1;
}
}
}
return n / m;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |