Submission #475434

#TimeUsernameProblemLanguageResultExecution timeMemory
475434HossamHero7Vođe (COCI17_vode)C++14
72 / 120
678 ms2512 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define endl '\n' int dp[505][505]; vector <int> v; int n,m,k; int solve(int i,int r){ int &ret = dp[i][r]; if(~ret) return ret; ret = 1 - v[i]; for(int j=r+1;j<=r+k;j++){ if(j<=m){ if(v[i] == 1){ ret = max(ret,solve((i+1)%n,j)); } else ret = min(ret,solve((i+1)%n,j)); } } return ret; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t=1; // cin>>t; while(t--){ memset(dp,-1,sizeof(dp)); cin>>n>>m>>k; v.resize(n); for(auto &i:v) cin>>i; for(int i=0;i<n;i++){ if(v[i] == 1){ int ans = 0; for(int j=1;j<=k;j++){ ans = max(ans,solve((i+1)%n,j+1)); } cout<<ans<<" "; } else { int ans = 1; for(int j=1;j<=k;j++){ ans = min(ans,solve((i+1)%n,j+1)); } cout<<ans<<" "; } } cout<<endl; } return 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...