UVa 620 Cellular Structure(DP)

题意  有A,B两种细胞  A细胞可由空生成  非空细胞链有两种增长方式  设O为原非空细胞链  则O可增长为OAB或BOA  给你一个细胞链  若其是合法分裂的  要求推断最后一次分裂是哪种方式  无法得到的输出MUTANT

若给定的S是以AB结尾的   推断去掉AB的部分是否合法就可以  若S是B開始A结束的   推断去掉首尾是否合法就可以。


#include <cstdio>  
#include <cstring>  
char s[10000];  
bool dp(int i, int j)  
{  
    if (i == j)  
        return s[i] == 'A' ? 1 : 0;  
    else if (s[j - 1] == 'A' && s[j] == 'B')  
        return dp(i, j - 2);  
    else if (s[i] == 'B' && s[j] == 'A')  
        return dp(i + 1, j - 1);  
    return 0;  
}  
int main()  
{  
    int t;  
    scanf("%d", &t);  
    while (t--)  
    {  
        scanf("%s", s + 1);  
        int l = strlen(s + 1);  
        if (!strcmp(s, "A"))  
            printf("SIMPLE\n");  
        else if (s[l - 1] == 'A' && s[l] == 'B' && dp(1, l - 2))  
            printf("FULLY-GROWN\n");  
        else if (s[1] == 'B' && s[l] == 'A' && dp(2, l - 1))  
            printf("MUTAGENIC\n");  
        else  
            printf("MUTANT\n");  
    }  
    return 0;  
}

 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



转载于:https://www.cnblogs.com/lxjshuju/p/7214546.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
经导师精心指导并认可、获 98 分的毕业设计项目!【项目资源】:微信小程序。【项目说明】:聚焦计算机相关专业毕设及实战操练,可作课程设计与期末大作业,含全部源码,能直用于毕设,经严格调试,运行有保障!【项目服务】:有任何使用上的问题,欢迎随时与博主沟通,博主会及时解答。 经导师精心指导并认可、获 98 分的毕业设计项目!【项目资源】:微信小程序。【项目说明】:聚焦计算机相关专业毕设及实战操练,可作课程设计与期末大作业,含全部源码,能直用于毕设,经严格调试,运行有保障!【项目服务】:有任何使用上的问题,欢迎随时与博主沟通,博主会及时解答。 经导师精心指导并认可、获 98 分的毕业设计项目!【项目资源】:微信小程序。【项目说明】:聚焦计算机相关专业毕设及实战操练,可作课程设计与期末大作业,含全部源码,能直用于毕设,经严格调试,运行有保障!【项目服务】:有任何使用上的问题,欢迎随时与博主沟通,博主会及时解答。 经导师精心指导并认可、获 98 分的毕业设计项目!【项目资源】:微信小程序。【项目说明】:聚焦计算机相关专业毕设及实战操练,可作课程设计与期末大作业,含全部源码,能直用于毕设,经严格调试,运行有保障!【项目服务】:有任何使用上的问题,欢迎随时与博主沟通,博主会及时解答。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值