Submission #368344

#TimeUsernameProblemLanguageResultExecution timeMemory
368344Ahmad_HasanVođe (COCI17_vode)C++17
72 / 120
3105 ms189276 KiB
#include <bits/stdc++.h> #define int long long /** |||||||||| ||||| ||||| |||||||||| ||||||||||||| ||||| ||||| ||||| |||| |||||| ||||| ||||| ||||| ||||||||||||||||| ||||||||||||||| |||||||||| ||||||||||||||||||| ||||||||||||||| ||||| ||||| ||||| ||||| ||||| ||||| ||||| ||||| ||||| ||||| |||||||||| AHMED;HASSAN;SAEED; */ using namespace std; int32_t main() { /**freopen("movie.in","r",stdin); freopen("movie.out","w",stdout);*/ int n,m,k; cin>>n>>m>>k; vector<int>v(n); for(int i=0;i<n;i++){ cin>>v[i]; } vector<vector<int> >dp(n+5,vector<int>(m+5,-2)); for(int i=0;i<n;i++){ dp[i][m]=0; dp[i][0]=-1; } for(int j=m;j>=0;j--){ for(int i=n-1;i>=0;i--){ for(int z=1;z<=k;z++){ if(z+j<=m){ if(j==0){ dp[i][j]=max(dp[i][j],dp[i][z]); } else{ if(v[i]==v[(i+1)%n]) dp[i][j]=max(dp[i][j],dp[(i+1)%n][j+z]); else{ if(dp[i][j]==-2) dp[i][j]=2; dp[i][j]=min(dp[i][j],1-dp[(i+1)%n][j+z]); } } } } } } /** for(int i=0;i<n;i++){ cout<<'#'; for(int j=0;j<=m;j++){ cout<<dp[i][j]<<' '; } cout<<'\n'; }*/ 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 */
#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...