uva620 - Cellular Structure(....)
来源:互联网 发布:予尚网络 编辑:程序博客网 时间:2024/06/05 06:39
这道题跟动规没一毛钱的关系啊,
我实在找不到状态转移,找不到记忆化搜索。。。
用dfs写的代码。。。跑了19ms
代码如下:
#include <cstdio>#include <cstring>#define N 105char s[N];char ans[4][20] = {"MUTANT","SIMPLE","FULLY-GROWN","MUTAGENIC"};int dfs(int a, int b){ if(s[a]=='A'&&a==b-1) return 1; if(s[b-2]=='A'&&s[b-1]=='B'&&dfs(a,b-2)!=0) return 2; if(s[a]=='B'&&s[b-1]=='A'&&dfs(a+1,b-1)!=0) return 3; return 0;}int main (){ int cas; scanf("%d",&cas); getchar(); while(cas--) { scanf("%s",s);getchar(); int len = strlen(s); printf("%s\n",ans[dfs(0,len)]); } return 0;}
- uva620 - Cellular Structure(....)
- UVA620- Cellular Structure
- uva620 - Cellular Structure
- uva 620 Cellular Structure
- UVA 620 Cellular Structure
- 620 - Cellular Structure
- UVa 620 - Cellular Structure
- uva 620 - Cellular Structure
- UVa 620 - Cellular Structure
- Uva-620-Cellular Structure
- uva 620 Cellular Structure
- uva 620 - Cellular Structure
- UVA - 620 Cellular Structure
- UVa:620 Cellular Structure
- uva 620 Cellular Structure
- UVa Cellular Structure
- UVA - 620 Cellular Structure
- UVA 620 Cellular Structure
- 博客人生从此开始
- C# Obsolete
- C# WPF 快速开发21拼接复合搜索的SQL语句
- Reverse Number
- C++中return的使用
- uva620 - Cellular Structure(....)
- 第五章 输入 小结
- Hibernate
- C# WPF 快速开发22Excel数据操作
- 计算几何算法概览
- C#常用的文件操作方法File类命名空间
- UVa 160-Factors and Factorials
- 主攻ASP.NET.4.5 MVC4.0之重生:可多选框数据存放
- Hibernate