This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |