UVA 620 Cellular Structure (dp)
| Cellular Structure |
A chain of connected cells of two types A and B composes a cellular structure of some microorganisms of species APUDOTDLS.
If no mutation had happened during growth of an organism, its cellular chain would take one of the following forms:
simple stage O = A
fully-grown stage O = OAB
mutagenic stage O = BOA
Sample notation O = OA means that if we added to chain of a healthy organism a cell A from the right hand side, we would end up also with a chain of a healthy organism. It would grow by one cell A.
A laboratory researches a cluster of these organisms. Your task is to write a program which could find out a current stage of growth and health of an organism, given its cellular chain sequence.
Input
A integer
n
being a number of cellular chains to test, and then
n
consecutive lines containing chains of tested organisms.
Output
For each tested chain give (in separate lines) proper answers:
SIMPLE for simple stage
FULLY-GROWN for fully-grown stage
MUTAGENIC for mutagenic stage
MUTANT any other (in case of mutated organisms)
If an organism were in two stages of growth at the same time the first option from the list above should be given as an answer.
Sample Input
4
A
AAB
BAAB
BAABA
Sample Output
SIMPLE
FULLY-GROWN
MUTANT
MUTAGENIC
题意:如题,一个细胞有三种生长方式。求出当前细胞的上一个生长方式。
思路:由当前细胞一直往之前的状态找即可。直到找到结束或者不能再往下找了位置。
代码:
#include <stdio.h>
#include <string.h> int t, len;
char ans[4][20] = {"SIMPLE", "FULLY-GROWN", "MUTANT", "MUTAGENIC"};
char str[1005]; int dp(int start, int end) {
if (end - start == 1 && str[start] == 'A') {
return 0;
}
else if (str[start] == 'B' && str[end - 1] == 'A') {
if (dp(start + 1, end - 1) != 2) {
return 3;
}
}
else if (str[end - 1] == 'B' && str[end - 2] == 'A') {
if (dp(start, end - 2) != 2) {
return 1;
}
}
return 2;
}
int main() {
scanf("%d%*c", &t);
while (t --) {
gets(str);
len = strlen(str);
printf("%s\n", ans[dp(0, len)]);
}
return 0;
}
UVA 620 Cellular Structure (dp)的更多相关文章
- uva 620 Cellular Structure
题目连接:620 - Cellular Structure 题目大意:给出一个细胞群, 判断该细胞的可能是由哪一种生长方式的到的, 输出该生长方式的最后一种生长种类, "SIMPLE&quo ...
- UVA 1386 - Cellular Automaton(循环矩阵)
UVA 1386 - Cellular Automaton option=com_onlinejudge&Itemid=8&page=show_problem&category ...
- UVA.674 Coin Change (DP 完全背包)
UVA.674 Coin Change (DP) 题意分析 有5种硬币, 面值分别为1.5.10.25.50,现在给出金额,问可以用多少种方式组成该面值. 每种硬币的数量是无限的.典型完全背包. 状态 ...
- uva 10817(数位dp)
uva 10817(数位dp) 某校有m个教师和n个求职者,需讲授s个课程(1<=s<=8, 1<=m<=20, 1<=n<=100).已知每人的工资c(10000 ...
- DP + 概率 + 贪心 UVA 1456 Cellular Network
题目传送门 题意:(摘自LRJ<训练指南>) 手机在蜂窝网络中的定位是一个基本问题.假设蜂窝网络已经得知手机处于c1, c2,…,cn这些区域中的一个,最简单的方法是同时在这些区域中寻找手 ...
- UVA 11404 Palindromic Subsequence[DP LCS 打印]
UVA - 11404 Palindromic Subsequence 题意:一个字符串,删去0个或多个字符,输出字典序最小且最长的回文字符串 不要求路径区间DP都可以做 然而要字典序最小 倒过来求L ...
- uva 10453 - Make Palindrome(dp)
题目链接:10453 - Make Palindrome 题目大意:给出一个字符串,通过插入字符使得原字符串变成一个回文串,要求插入的字符个数最小,并且输出最后生成的回文串. 解题思路:和uva 10 ...
- uva 10671 - Grid Speed(dp)
题目链接:uva 10671 - Grid Speed 题目大意:给出N,表示在一个N*N的网格中,每段路长L,如今给出h,v的限制速度,以及起始位置sx,sy,终止位置ex,ey,时间范围st,et ...
- uva 1331 - Minimax Triangulation(dp)
option=com_onlinejudge&Itemid=8&page=show_problem&category=514&problem=4077&mosm ...
随机推荐
- jquery Deferred使用经验
这周做了个小活动(http://aoqi.100bt.com/zt-2016duanzi/index.html),刚开始时候没看好需求,逻辑都写一块了 最后各种坑要填补,从中也获取了些经验和教训,下面 ...
- C#多线程的死锁演示
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.D ...
- @Autowired 注释与@Qualifier 注释
@Service("OrganDaoIbatis") public class OrganDaoIbatis extends BaseDao implements IOrganDa ...
- perl 类里的函数调用其他类的函数
perl 类里的函数调用其他类的函数: package Horse; use base qw(Critter); sub new { my $invocant = shift; my $class = ...
- hdu1391(Number Steps )
Problem Description Starting from point (0,0) on a plane, we have written all non-negative integers ...
- spring中bean的一些知识点
知识点1: 实例化bean的3种方法. 1. 使用类构造器 (90%用这个方法) 2. 使用静态工厂方法 3. 使用实例化工厂 知识点2: 看这段代码 Applicati ...
- Selenium 出现: Caused by: java.lang.ClassNotFoundException: org.w3c.dom.ElementTraversal
webDriver 运行的时候出现: Caused by: java.lang.ClassNotFoundException: org.w3c.dom.ElementTraversal 解决办法: 只 ...
- 自拉ADSL网线搭建站点server,解决动态IP、无公网IP、80port被封、HTTP被屏蔽的方法
自己的server搭建站点应用,提供站点服务,能够不用备案,但可能会面对网络限制问题,如动态公网IP.无公网IP.80port被封.HTTP被屏蔽,这些复杂网络情况. 依据本地网络环境,能够针对不同的 ...
- Logistic Regression(逻辑回归)(二)—深入理解
(整理自AndrewNG的课件,转载请注明.整理者:华科小涛@http://www.cnblogs.com/hust-ghtao/) 上一篇讲解了Logistic Regression的基础知识,感觉 ...
- JavaScript常用全局属性与方法
最近,在学习JavaScript,Java作域链包含全局,记录下常用的全局属性与方法,就当是知识的积累,未列出全部,如需查看全部可参考JS相关的API文档. 常用的全局属性: 全局属性 作 ...
