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)的更多相关文章

  1. uva 620 Cellular Structure

    题目连接:620 - Cellular Structure 题目大意:给出一个细胞群, 判断该细胞的可能是由哪一种生长方式的到的, 输出该生长方式的最后一种生长种类, "SIMPLE&quo ...

  2. UVA 1386 - Cellular Automaton(循环矩阵)

    UVA 1386 - Cellular Automaton option=com_onlinejudge&Itemid=8&page=show_problem&category ...

  3. UVA.674 Coin Change (DP 完全背包)

    UVA.674 Coin Change (DP) 题意分析 有5种硬币, 面值分别为1.5.10.25.50,现在给出金额,问可以用多少种方式组成该面值. 每种硬币的数量是无限的.典型完全背包. 状态 ...

  4. uva 10817(数位dp)

    uva 10817(数位dp) 某校有m个教师和n个求职者,需讲授s个课程(1<=s<=8, 1<=m<=20, 1<=n<=100).已知每人的工资c(10000 ...

  5. DP + 概率 + 贪心 UVA 1456 Cellular Network

    题目传送门 题意:(摘自LRJ<训练指南>) 手机在蜂窝网络中的定位是一个基本问题.假设蜂窝网络已经得知手机处于c1, c2,…,cn这些区域中的一个,最简单的方法是同时在这些区域中寻找手 ...

  6. UVA 11404 Palindromic Subsequence[DP LCS 打印]

    UVA - 11404 Palindromic Subsequence 题意:一个字符串,删去0个或多个字符,输出字典序最小且最长的回文字符串 不要求路径区间DP都可以做 然而要字典序最小 倒过来求L ...

  7. uva 10453 - Make Palindrome(dp)

    题目链接:10453 - Make Palindrome 题目大意:给出一个字符串,通过插入字符使得原字符串变成一个回文串,要求插入的字符个数最小,并且输出最后生成的回文串. 解题思路:和uva 10 ...

  8. uva 10671 - Grid Speed(dp)

    题目链接:uva 10671 - Grid Speed 题目大意:给出N,表示在一个N*N的网格中,每段路长L,如今给出h,v的限制速度,以及起始位置sx,sy,终止位置ex,ey,时间范围st,et ...

  9. uva 1331 - Minimax Triangulation(dp)

    option=com_onlinejudge&Itemid=8&page=show_problem&category=514&problem=4077&mosm ...

随机推荐

  1. 基于visual Studio2013解决面试题之1404希尔排序

     题目

  2. VC动态轨迹画线

    分类: 2.4 线程/图形学2010-04-30 22:14 1878人阅读 评论(0) 收藏 举报 文档null 这是一个绘制直线的简单绘图程序,能过实现动态轨迹画线,在拖动时产生临时线来表示可能画 ...

  3. javascript 浏览器兼容性写法

    var event = window.event || arguments.callee.caller.arguments[0]; // 获取event对象 event = event.srcElem ...

  4. 有N个正实数(注意是实数,大小升序排列) x1 , x2 ... xN,另有一个实数M。 需要选出若干个x,使这几个x的和与 M 最接近。 请描述实现算法,并指出算法复杂度

    题目:有N个正实数(注意是实数,大小升序排列) x1 , x2 ... xN,另有一个实数M. 需要选出若干个x,使这几个x的和与 M 最接近. 请描述实现算法,并指出算法复杂度. 代码如下: #in ...

  5. linux下编译qt5.6.0静态库——configure配置(超详细,有每一个模块的说明)(乌合之众)

    linux下编译qt5.6.0静态库 linux下编译qt5.6.0静态库 configure生成makefile 安装选项 Configure选项 第三方库: 附加选项: QNX/Blackberr ...

  6. QString与char*的相互转换

    原地址:http://blog.sina.com.cn/s/blog_5c70dfc80100r0nh.html 一.QString转char*   QString str; int num=0; s ...

  7. JavaScript编程:浏览器对象模型BOM

    4.浏览器对象模型BOM: document.body.offsetwidth可以获取浏览器宽度. Window对象:          窗口操作:            1.moveBy(dx,dy ...

  8. 核心游记之 page_address_init

    lock_kernel()仅仅虚晃一枪就过去了. 紧接着来的是page_address_init include/linux/mm.h   #if defined(CONFIG_HIGHMEM) &a ...

  9. 几本不错的CPU设计以及VLSI的书籍

    1. Microprocessor Design Principales and Practrices with VHDL  特点:电路与VHDL一一对应,比较清楚,而且还用MAX+plus进行仿真 ...

  10. 【IACV】边缘检测技术传统的方法与理论

    1.边缘检测的目的 边缘检测是图像分析中使用到的最常见的操作之一,而且相比其他任何主题来说,文献中提到的与边缘增强(edge enhancement)[1]与边缘检测(edge detection)[ ...