#include <bits/stdc++.h>
#define int int16_t
/**
|||||||||| ||||| ||||| ||||||||||
||||||||||||| ||||| ||||| |||||
|||| |||||| ||||| ||||| |||||
||||||||||||||||| ||||||||||||||| ||||||||||
||||||||||||||||||| ||||||||||||||| |||||
||||| ||||| ||||| ||||| |||||
||||| ||||| ||||| ||||| ||||||||||
AHMED;HASSAN;SAEED;
*/
using namespace std;
int32_t main()
{
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int n,m,k;
cin>>n>>m>>k;
vector<int>v(n);
for(int i=0;i<n;i++){
cin>>v[i];
}
int dp[n][m+5];
for(int i=0;i<n;i++){
dp[i][m]=0;
dp[i][0]=-1;
}
int cntr[n][m+5][2];
memset(cntr,0,sizeof(cntr));
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]){
if(cntr[(i+1)%n][j+1][1])
dp[i][j]=1;
else
dp[i][j]=0;
}
else{
if(cntr[(i+1)%n][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 |
0 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
748 KB |
Output is correct |
2 |
Correct |
1 ms |
492 KB |
Output is correct |
3 |
Correct |
2 ms |
748 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
748 KB |
Output is correct |
2 |
Correct |
1 ms |
620 KB |
Output is correct |
3 |
Correct |
2 ms |
748 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
1004 KB |
Output is correct |
2 |
Correct |
3 ms |
1132 KB |
Output is correct |
3 |
Correct |
3 ms |
1132 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
1644 KB |
Output is correct |
2 |
Correct |
4 ms |
1664 KB |
Output is correct |
3 |
Correct |
3 ms |
1260 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
1516 KB |
Output is correct |
2 |
Correct |
5 ms |
1516 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
133 ms |
17900 KB |
Output is correct |
2 |
Correct |
90 ms |
20204 KB |
Output is correct |
3 |
Correct |
1157 ms |
129120 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
204 ms |
42348 KB |
Output is correct |
2 |
Correct |
645 ms |
115692 KB |
Output is correct |
3 |
Correct |
362 ms |
44940 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1253 ms |
141988 KB |
Output is correct |
2 |
Correct |
12 ms |
3712 KB |
Output is correct |
3 |
Correct |
4 ms |
2288 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1206 ms |
140780 KB |
Output is correct |
2 |
Correct |
1061 ms |
125804 KB |
Output is correct |
3 |
Correct |
711 ms |
139504 KB |
Output is correct |