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;
#define finish(x) return cout << x << endl, 0
#define ll long long
const int N = 5001;
int n, m, k, dp[N][N], cnt[N][2];
vector <int> a;
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n >> m >> k;
a.resize(n);
for(auto &i : a) cin >> i;
for(int i = 0 ; i < n ; i++){
cnt[i][0] = 1;
}
for(int c = m - 1 ; c >= 1 ; c--){
for(int i = 0 ; i < n ; i++){
if(c + k + 1 <= m){
cnt[i][dp[i][c + k + 1]]--;
}
}
for(int i = 0 ; i < n ; i++){
int g = (i + 1) % n;
//~ for(int j = c + 1 ; j <= min(m, c + k) ; j++){
//~ if(a[i] == a[g] && dp[g][j]) dp[i][c] = 1;
//~ if(a[i] != a[g] && dp[g][j] == 0) dp[i][c] = 1;
//~ }
if(a[i] == a[g]) dp[i][c] = (bool)cnt[g][1];
else dp[i][c] = (bool)cnt[g][0];
}
for(int i = 0 ; i < n ; i++){
cnt[i][dp[i][c]]++;
}
}
for(int i = 0 ; i < n ; i++){
cout << (dp[i][1] ^ a[i] ^ 1) << " ";
}
cout << endl;
}
# | 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... |