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 ...
随机推荐
- git add --all 为啥不能添加空文件夹,这样设计的初衷是
git add --all 为啥不能添加空文件夹,这样设计的初衷是? 好多项目还得弄个假文件在空文件夹里面占位 这个算设计失误吧,见 https://git.wiki.kernel.org/index ...
- java 一个函数EnumMap返回多个值
java 一个函数如何返回多个值 在开发过程中,经常会有这种情况,就是一个函数需要返回多个值,这是一个问题!! 网上这个问题的解决方法: 1.使用map返回值:这个方法问题是,你并不知道如何返回值 ...
- js遍历对象的数组
遍历数组: 1.js关键for遍历 2.jquery提供each功能 ----------------------------------- $.each(array, function(){ ...
- CSS3实现8种Loading效果【第二波】
原文:CSS3实现8种Loading效果[第二波] 今晚吃完饭回宿舍又捣鼓了另外几种Loading效果,老规矩,直接“上菜“…… 注:gif图片动画有些卡顿,非实际效果! PS:若要转载请注明出处,尊 ...
- 北京出dell s2740显示器 1900 - V2EX
水木社区归档站 北京出dell s2740显示器 1900 - V2EX 北京出dell s2740显示器 1900 By kekex · 6 小时 6 分钟前 · 188 次点击 购于今年4月份 镜 ...
- 定义自己的仪表板DashBoard - -kankanstyle
既然做了奶站软件,需要使用的仪表板,显示质量数据 public class MDashboard extends ImageView { private Bitmap mPointerBitmap; ...
- Beauty of Array
Description Edward has an array A with N integers. He defines the beauty of an array as the summatio ...
- 改变TPageControl的活动标签颜色
设置PageControl的owndraw属性为TRUE. procedure TForm1.pgc1DrawTab(Control: TCustomTabControl; TabIndex: Int ...
- 窗口绘制有关的消息整理 WM_PAINT, WM_NCPAINT, WM_ERASEBKGND
WM_PAINTWM_PAINT是Windows窗口系统中一条重要的消息,应用程序通过处理该消息实现在窗口上的绘制工作. WM_NCPAINT当窗口客户区以外的部分(如窗口标题栏.菜单栏等)需要需要重 ...
- CDialogBar(对话条)和CReBar(伸缩条)的编程
对话条是工具栏和无模式对话框相结合的产物,对话条和对话框类似,包含有标准的Windows控件,并且可以通过创建对话框模板来表示对话条. 伸缩条功能很强大,我们可以在伸缩条中直接增加CToolBar,C ...