Codeforces Round #442 (Div. 2) C. Slava and tanks
来源:互联网 发布:java事务怎么实现 编辑:程序博客网 时间:2024/06/18 11:28
陷入了靠前焦虑状态,好长时间没做过题了吧,水题一个没想起来。。
-------------------因为热爱,所以执着-----------------
继续补题,不急慢慢来。
#include<bits/stdc++.h>using namespace std;#define pb push_back#define mp make_pairchar s[5005];int dp[5005][5],n;int solve(int pos,int now){ if(now>3||pos>n)return 0; if(dp[pos][now]!=-1)return dp[pos][now]; int res=0; if(now==1||now==3) { if(s[pos]=='a') res=max(res,1+solve(pos+1,now)); else res=max(res,solve(pos+1,now)); } if(now==2) { if(s[pos]=='b') res=max(res,1+solve(pos+1,now)); else res=max(res,solve(pos+1,now)); } if(now<3) { res=max(res,solve(pos,now+1)); } dp[pos][now]=res; return dp[pos][now];}int main(){scanf("%s",s+1);n=strlen(s+1);memset(dp,-1,sizeof(dp));printf("%d\n",solve(1,1)); return 0;}
阅读全文
0 0
- Codeforces Round #442 (Div. 2) C. Slava and tanks
- Codeforces 877(442 Div.2) C. Slava and tanks
- Codeforces Round #442 (Div. 2) C. Slava and tanks 【找规律】
- #442 Div.2 AB &C. Slava and tanks 思维题
- Codeforces 877 C Slava and tanks
- codeforces877C(div2)Slava and tanks(脑洞)
- Codeforces Round #179 (Div. 2) C. Greg and Array
- Codeforces Round #179 (Div. 2) C Greg and Array
- Codeforces Round#179(Div 2)C Greg and Array
- Codeforces Round #197 (Div. 2) C. Xenia and Weights - 搜索
- Codeforces Round #197 (Div. 2) c. Xenia and Weights
- Codeforces Round #199 (Div. 2) C. Cupboard and Balloons
- Codeforces Round #199 (Div. 2) C. Cupboard and Balloons
- Codeforces Round #201 (Div. 2) C. Alice and Bob
- Codeforces Round #204 (Div. 2) C. Jeff and Rounding
- Codeforces Round #206 (Div. 2) C - Vasya and Robot
- Codeforces Round #206 (Div. 2) C. Vasya and Robot
- Codeforces Round #204 (Div. 2) C Jeff and Rounding
- Python装饰器
- java 网络客户机与服务器的交互
- 搜狗浏览器的技巧
- js中那些让你不知所措的闭包
- Microsoft VBScript 运行时错误 错误 '800a0046' 没有权限
- Codeforces Round #442 (Div. 2) C. Slava and tanks
- spring boot——logback基本配置
- 图库
- 花生壳远程桌面连接
- C++ string 字符串查找匹配
- LaTex(PART XIII)\newcommand自定义命令
- 简要总结良好的C++编程习惯
- JavaScript正则表达式大全
- 咿呀,字典是无序的