#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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
632 KB |
Output is correct |
3 |
Correct |
5 ms |
504 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
1276 KB |
Output is correct |
2 |
Correct |
5 ms |
888 KB |
Output is correct |
3 |
Correct |
6 ms |
1400 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
1528 KB |
Output is correct |
2 |
Correct |
6 ms |
1400 KB |
Output is correct |
3 |
Correct |
6 ms |
1528 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
2168 KB |
Output is correct |
2 |
Correct |
8 ms |
2424 KB |
Output is correct |
3 |
Correct |
8 ms |
2296 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
3064 KB |
Output is correct |
2 |
Correct |
9 ms |
2808 KB |
Output is correct |
3 |
Correct |
9 ms |
2680 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
2680 KB |
Output is correct |
2 |
Correct |
9 ms |
2808 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
104 ms |
19168 KB |
Output is correct |
2 |
Correct |
162 ms |
20740 KB |
Output is correct |
3 |
Correct |
1070 ms |
94596 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
334 ms |
38392 KB |
Output is correct |
2 |
Correct |
926 ms |
94524 KB |
Output is correct |
3 |
Correct |
339 ms |
41208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1127 ms |
95456 KB |
Output is correct |
2 |
Correct |
13 ms |
2552 KB |
Output is correct |
3 |
Correct |
8 ms |
1656 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1106 ms |
96060 KB |
Output is correct |
2 |
Correct |
965 ms |
96376 KB |
Output is correct |
3 |
Correct |
756 ms |
96632 KB |
Output is correct |