This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
int a[5005], f[5005][5005];
int main()
{
int n, m, k;
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, l = j + 1, r = min(j + k, m);
bool val = 0;
f[i][j] = f[i][j + 1];
if (a[i] != a[nxt]) val = ((f[nxt][l] - f[nxt][r + 1]) != (r - l + 1));
if (a[i] == a[nxt]) val = ((f[nxt][l] - f[nxt][r + 1]) > 0);
f[i][j] += val;
}
for (int i = 0; i < n; i++)
if (f[i][1] != f[i][0]) cout << a[i] << " "; else cout << (1 + a[i]) % 2 << " ";
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |