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 ...
随机推荐
- cocos2d-x游戏开发系列教程-坦克大战游戏之虚拟手柄控制坦克移动
上篇显示了控制手柄,但是还不能用来控制坦克, 这篇将会讲手柄和坦克的移动结合起来. 1.先在CityScene场景中实现场景的虚函数virtual void onEnter(); onEnter在进入 ...
- [置顶] Java 8全面解析!不知道的来看看那!
java8的面世惊动了不少业界人员,让我们一起来看看吧! 函数式接口 函数式接口是只定义了一个抽象方法的接口.Java 8引入了FunctionalInterface注解来表明一个接口打算成为一个函数 ...
- 测试 __try, __finally, __except(被__finally捕获的异常, 还会被上一级的__except捕获。反之不行)
C语言标准是没有 try-catch语法 的, M$家自己提供了一组. /// @file ClassroomExamples.c /// @brief 验证C语言的非标准try, catch #in ...
- 【Nginx笔记】nginx配置文件具体解释
本文主要对nginx的配置做重点说明,关于nginx的其他基本概念.建议參考官网描写叙述.这里推荐Nginx Beginner's Guide这篇文档.对刚開始学习的人高速认识nginx非常有帮助. ...
- Java批量生成Mac地址到文件
public class Main { public static void main(String[] args) { // 生成文件名称 String filePath = "mac.t ...
- ORA-00942:表或视图不存在(低级错误)
在好多时候.调试PL/SQL对象时会报.ORA-00942 看看错误原因吧: watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvamFjc29uX2JhaQ== ...
- C++学习之路—继承与派生(四)拓展与总结
(根据<C++程序设计>(谭浩强)整理,整理者:华科小涛,@http://www.cnblogs.com/hust-ghtao转载请注明) 1 拓展部分 本节主要由两部分内容组成,分 ...
- Servlet的学习之web路径问题
在这个篇章中,我们来学习下在web开发过程中会碰到的路径写法问题. 在之前的web应用开发,尤其是Servlet的学习过程中,我们碰到多次要写路径的问题,这些路径并不统一,因此这里将大致说明下各个方法 ...
- python发送各类邮件的主要方法
更多详见: http://www.w3cschool.cc/python/python-email.html python中email模块使得处理邮件变得比较简单,今天着重学习了一下发送邮件的具体做法 ...
- 党建凯,创新工场知乎团队Web前端工程师
Nicholas C. Zakas谈怎样才能成为优秀的前端工程师: 昨天,我负责了Yahoo!公司组织的一次面试活动,感触颇深的是其中的应聘者提问环节.我得说自己对应聘者们提出的大多数问题都相当失望. ...