官方题解|挑战赛#6
2024-07-15 10:30:59
发布于:浙江
全部评论 5
#include<bits/stdc++.h> using namespace std; bool vis[105][105]; long long answer ; char mp[105][105]; long long dp[105][105]; long long n,t,k,z,sx,sy; int main() { int n; cin >> n >> t >> k >> z >> sx >> sy; for(int i = 1 ; i <= n ; i ++ ){ for(int j = 1 ; j <= n ; j ++ ){ cin >> mp[i][j]; } } dp[sx][sy] = t; if(mp[sx][sy] == 'D')dp[sx][sy] += z; for(int i = sx+1 ; i <= n ; i ++ ){ dp[i][sy] = dp[i-1][sy]; if(mp[i][sy] == 'D')dp[i][sy] += z; if(mp[i][sy] == '.')dp[i][sy] -= 1; if(mp[i][sy] == 'M')dp[i][sy] -= k; } for(int i = sy + 1 ; i <= n ; i ++ ) { dp[sx][i] = dp[sx][i-1]; if(mp[sx][i] == 'D')dp[sx][i] += z; if(mp[sx][i] == '.')dp[sx][i] -= 1; if(mp[sx][i] == 'M')dp[sx][i] -= k; } for(int i = sx + 1 ; i <= n ; i ++ ) { for(int j = sy + 1 ; j <= n ; j ++ ) { if(mp[i][j] == 'D')dp[i][j] += z; if(i==sx&&j==sy)continue; dp[i][j] += max(dp[i-1][j],dp[i][j-1]); if(mp[i][j] == '.')dp[i][j] -= 1; if(mp[i][j] == 'M')dp[i][j] -= k; } } cout <<dp[n][n] << endl; return 0; }
2024-07-12 来自 广东
0#include<bits/stdc++.h> using namespace std; int main() { long long s,m,w; cin >> s >> m >> w; if(s < m){ cout << "Come back" << endl; } else if(s >= m && s <= w){ cout << "You can do it , but be careful" << endl; } else { cout << "Go,now!" << endl; } return 0; }
2024-07-12 来自 广东
0666
2024-07-12 来自 广东
0qp
2024-07-08 来自 北京
06
2024-07-08 来自 广东
0
有帮助,赞一个