#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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
1228 KB |
Output is correct |
2 |
Correct |
3 ms |
1228 KB |
Output is correct |
3 |
Correct |
1 ms |
1228 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
1228 KB |
Output is correct |
2 |
Correct |
11 ms |
1312 KB |
Output is correct |
3 |
Correct |
56 ms |
1320 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
12 ms |
1228 KB |
Output is correct |
2 |
Correct |
59 ms |
1308 KB |
Output is correct |
3 |
Correct |
8 ms |
1228 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
41 ms |
1228 KB |
Output is correct |
2 |
Correct |
107 ms |
1316 KB |
Output is correct |
3 |
Correct |
16 ms |
1228 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
38 ms |
1228 KB |
Output is correct |
2 |
Correct |
55 ms |
1324 KB |
Output is correct |
3 |
Correct |
285 ms |
1312 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
1228 KB |
Output is correct |
2 |
Correct |
83 ms |
1228 KB |
Output is correct |
3 |
Correct |
1 ms |
1228 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
54 ms |
2500 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
236 ms |
2492 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
678 ms |
2512 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
506 ms |
2464 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |