#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define vt vector
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(x) (int) (x).size()
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define EACH(x, a) for (auto& x : a)
#define print(x) cout << x << endl
#pragma GCC optimize ("O3")
#pragma GCC optimize ("O2")
//#define endl '\n'
//#define int long long
using namespace std;
int subtask1(int N, int M, int K, vt<int> C, vt<int> A, vt<vt<int>> B)
{
map<int, int> MP;
FOR(i, 0, M - 1)
{
MP[B[i][0]] = i + 1;
}
int ans = 0, i = 0, lst = -1;
while(i <= N - M)
{
//print(i);
if (i == lst) return -1;
int j = MP[C[i]] - 1;
if (j == -1) return -1;
bool flag = 0;
FOR(l, 0, M - 1)
{
if (B[(j + l) % M][0] != C[i + l])
{
i--;
flag = 1;
break;
}
}
if (flag) continue;
ans++;
lst = i;
i += M;
}
if (i != N) return 5 / 0;
return ans;
}
int minimumInstructions(int N, int M, int K, vt<int> C, vt<int> A, vt<vt<int>> B)
{
bool sub1 = 1;
FOR(i, 0, M - 1)
{
if (A[i] != 1)
{
sub1 = 0;
break;
}
}
if (sub1) return subtask1(N, M, K, C, A, B);
}
/**
main()
{
ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int ans = minimumInstructions(10, 4, 4, {1, 0, 3, 2, 1, 0, 2, 1, 0, 3}, {1, 1, 1, 1}, {{2}, {1}, {0}, {3}});
print(ans);
}
/**/
Compilation message
paint.cpp:72:1: warning: "/*" within comment [-Wcomment]
72 | /**/
|
paint.cpp: In function 'int subtask1(int, int, int, std::vector<int>, std::vector<int>, std::vector<std::vector<int> >)':
paint.cpp:47:26: warning: division by zero [-Wdiv-by-zero]
47 | if (i != N) return 5 / 0;
| ~~^~~
paint.cpp: In function 'int minimumInstructions(int, int, int, std::vector<int>, std::vector<int>, std::vector<std::vector<int> >)':
paint.cpp:63:1: warning: control reaches end of non-void function [-Wreturn-type]
63 | }
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |