uva 620 - Cellular Structure

1、http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=561

2、题目好难懂。。。

给定一个细胞链,只有AB两种字母组成,有三种方式,一种是OA,一种是OAB,一种是BOA,O代表是正常的细胞链,最后看一下这个细胞链是否是由这些组合构成的,如果有多种方式构成,输出排在前边的方式。如果不是这三种方式中的一种,那么该细胞链已变异,作为第四种输出

3、题目:

 

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:


$\bullet$
simple stage 		 O = A  
$\bullet$
fully-grown stage 		 O = OAB 
$\bullet$
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 thenn 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

 

4、AC代码:

#include<stdio.h>
#include<string.h>
char str[100];
int ans;
int DP(int start,int end)
{
    if(start==end && str[start]=='A')
    return 1;
    else if(end-start>=1 && str[end]=='A' && DP(start,end-1))
    return 1;
    else if(end-start>=2 && str[end]=='B' && str[end-1]=='A' && DP(start,end-2))
    return 2;
    else if(end-start>=2 && str[end]=='A' && str[start]=='B' && DP(start+1,end-1))
    return 3;
    return 0;
}
int main()
{
    int n;
    scanf("%d",&n);
    while(n--)
    {
        scanf("%s",str);
        int l=strlen(str);
        int ans=DP(0,l-1);
        if(ans==1)
        printf("SIMPLE\n");
        else if(ans==2)
        printf("FULLY-GROWN\n");
        else if(ans==3)
        printf("MUTAGENIC\n");
        else
        printf("MUTANT\n");
    }
    return 0;
}


 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值