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>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
const int maxn = 5e3 + 5;
int f[maxn][maxn], num[2][maxn], a[maxn];
int N, M, K;
signed main(void)
{
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifdef LOCAL
freopen("A.INP", "r", stdin);
freopen("A.OUT", "w", stdout);
#endif // LOCAL
cin >> N >> M >> K;
for(int i = 1; i <= N; ++i){
cin >> a[i];
f[i][M - 1] = a[i] ^ 1;
num[a[i] ^ 1][i]++;
}
for(int j = M - 2; j >= 0; --j){
for(int i = 1; i <= N; ++i){
int nxt = i + 1; if(nxt > N) nxt -= N;
if(num[a[i]][nxt]) f[i][j] = a[i];
else f[i][j] = a[i] ^ 1;
}
for(int i = 1; i <= N; ++i){
num[f[i][j]][i]++;
if(j + K < M) num[f[i][j + K]][i]--;
}
}
for(int i = 1; i <= N; ++i)
cout << f[i][0] << ' ';
}
# | 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... |