Submission #369215

#TimeUsernameProblemLanguageResultExecution timeMemory
369215Ahmad_HasanVođe (COCI17_vode)C++17
120 / 120
798 ms144548 KiB
#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])?v[i]:1-v[i])<<' '; return 0; } /** 6 20 5 1 0 0 1 1 0 */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...