#include <bits/stdc++.h>
#define int int16_t
/**
|||||||||| ||||| ||||| ||||||||||
||||||||||||| ||||| ||||| |||||
|||| |||||| ||||| ||||| |||||
||||||||||||||||| ||||||||||||||| ||||||||||
||||||||||||||||||| ||||||||||||||| |||||
||||| ||||| ||||| ||||| |||||
||||| ||||| ||||| ||||| ||||||||||
AHMED;HASSAN;SAEED;
*/
using namespace std;
int dp[5000][5000+5],cntr[5000][5000+5][2],v[5000];
int32_t main()
{
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int n,m,k;
cin>>n>>m>>k;
for(int i=0;i<n;i++){
cin>>v[i];
}
for(int i=0;i<n;i++){
dp[i][m]=0;
}
for(int i=0;i<n;i++)
cntr[i][m][0]=1;
for(int j=m-1;j>=0;j--){
for(int i=n-1;i>=0;i--){
if(j==0){
if(cntr[i][j+1][1])
dp[i][j]=1;
else
dp[i][j]=0;
}
else{
if(v[i]==v[((i+1)==n?0:i+1)]){
if(cntr[((i+1)==n?0:i+1)][j+1][1])
dp[i][j]=1;
else
dp[i][j]=0;
}
else{
if(cntr[((i+1)==n?0:i+1)][j+1][1])
dp[i][j]=0;
else
dp[i][j]=1;
}
}
cntr[i][j][0]=cntr[i][j+1][0];
cntr[i][j][1]=cntr[i][j+1][1];
cntr[i][j][dp[i][j]]++;
if(j+k<=m){
cntr[i][j][dp[i][j+k]]--;
}
}
}
for(int i=0;i<n;i++)
cout<<((dp[i][0]==1)?v[i]:!v[i])<<' ';
return 0;
}
/**
6 20 5
1 0 0 1 1 0
*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
1004 KB |
Output is correct |
3 |
Correct |
1 ms |
876 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
2156 KB |
Output is correct |
2 |
Correct |
1 ms |
1260 KB |
Output is correct |
3 |
Correct |
2 ms |
2156 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
2540 KB |
Output is correct |
2 |
Correct |
2 ms |
2412 KB |
Output is correct |
3 |
Correct |
2 ms |
2668 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
3564 KB |
Output is correct |
2 |
Correct |
5 ms |
4204 KB |
Output is correct |
3 |
Correct |
4 ms |
4076 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
5356 KB |
Output is correct |
2 |
Correct |
5 ms |
4972 KB |
Output is correct |
3 |
Correct |
4 ms |
4716 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
4716 KB |
Output is correct |
2 |
Correct |
7 ms |
4992 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
100 ms |
32216 KB |
Output is correct |
2 |
Correct |
113 ms |
34796 KB |
Output is correct |
3 |
Correct |
811 ms |
141932 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
230 ms |
62316 KB |
Output is correct |
2 |
Correct |
679 ms |
141676 KB |
Output is correct |
3 |
Correct |
237 ms |
67052 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
791 ms |
142828 KB |
Output is correct |
2 |
Correct |
6 ms |
3692 KB |
Output is correct |
3 |
Correct |
3 ms |
2284 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
788 ms |
143908 KB |
Output is correct |
2 |
Correct |
712 ms |
144236 KB |
Output is correct |
3 |
Correct |
687 ms |
144492 KB |
Output is correct |