#include <bits/stdc++.h>
#define pb push_back
using namespace std;
const int N = 5e3 + 10;
int n, m, k, a[N], f[N][N];
int main() {
cin >> n >> m >> k;
for (int i = 0; i < n; ++i)
cin >> a[i];
for (int i = 0; i < n; i++)
f[(i + 1) % n][m] = (a[i] != a[(i + 1) % n]);
for (int j = m - 1; j >= 0; --j)
for (int i = 0; i < n; ++i) {
int nxt = (i + 1) % n;
bool gd = 0;
if (a[i] != a[nxt]) {
for (int l = j + 1; l <= min(j + k, m); ++l)
gd |= !(f[nxt][l]);
} else {
for (int l = j + 1; l <= min(j + k, m); ++l)
gd |= f[nxt][l];
}
f[i][j] = gd;
}
for (int i = 0; i < n; i++)
cout << (f[i][0] ? a[i] : a[i] ^ 1) << ' ';
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
640 KB |
Output is correct |
3 |
Correct |
5 ms |
512 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
1280 KB |
Output is correct |
2 |
Correct |
6 ms |
768 KB |
Output is correct |
3 |
Correct |
13 ms |
1280 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
1536 KB |
Output is correct |
2 |
Correct |
12 ms |
1408 KB |
Output is correct |
3 |
Correct |
6 ms |
1536 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
12 ms |
2048 KB |
Output is correct |
2 |
Correct |
21 ms |
2432 KB |
Output is correct |
3 |
Correct |
8 ms |
2304 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
12 ms |
3072 KB |
Output is correct |
2 |
Correct |
14 ms |
2816 KB |
Output is correct |
3 |
Correct |
40 ms |
2680 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
2688 KB |
Output is correct |
2 |
Correct |
20 ms |
2816 KB |
Output is correct |
3 |
Correct |
4 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
204 ms |
19224 KB |
Output is correct |
2 |
Correct |
806 ms |
20984 KB |
Output is correct |
3 |
Execution timed out |
3077 ms |
47464 KB |
Time limit exceeded |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1244 ms |
38264 KB |
Output is correct |
2 |
Execution timed out |
3102 ms |
48376 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
3077 ms |
46300 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
3069 ms |
51256 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |