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 ...
随机推荐
- LWP::UserAgent - Web user agent class Web 用户agent 类:
LWPUserAgent: LWP::UserAgent - Web user agent class Web 用户agent 类: 概述: require LWP::UserAgent; my $u ...
- Redis bio
还是一个很小的模块. bio就是background io的意思,既然要background,就要创建线程,创建几个线程呢?有几种类型的io,就创建几个线程.同一种类型的job需要排队,所以存放各自的 ...
- HDU 2328 POJ 3450 KMP
题目链接: HDU http://acm.hdu.edu.cn/showproblem.php?pid=2328 POJhttp://poj.org/problem?id=3450 #include ...
- 【剑指offer】树的子结构
转载请注明出处:http://blog.csdn.net/ns_code/article/details/25907685 剑指offer第18题,九度OJ上測试通过! 题目描写叙述: 输入两颗二叉树 ...
- 重操JS旧业第四弹:Date与Global对象
1 Date原理 Date类型表示时间,js中采用UTC国际协调时间,以1971年1月1日0分0秒0微秒开始,经过的毫秒数来表示时间,比如一年的时间计算 1分:1000*60: 1小时:1000(毫秒 ...
- 基于visual Studio2013解决面试题之0702输出数字
题目
- MFC超链接静态类的使用
源代码:http://download.csdn.net/detail/nuptboyzhb/4197151 CHyperLink类,是由CStatic类派生出来,重载了CStatic类的如下函数: ...
- dataStage 7.5.1A
------------------------------ DataStage Server License ------------------------------ Serial Num ...
- 14.1.1 InnoDB as the Default MySQL Storage Engine
14.1 Introduction to InnoDB 14.1.1 InnoDB as the Default MySQL Storage Engine 14.1.2 Checking InnoDB ...
- grub配置文件grub.conf详细说明
说明:只供学习交流 default行,是指grub启动时默认菜单项.0表示第一项,如果是多系统可以修改此选项改变默认光标停留位置. timeout行,是指菜单到自动启动系统前的停留时间,单位时间为se ...
