Uva--620(动规)

2014-08-02 16:23:46

  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

思路:按几种生长方式从两边向中间逼近,直到一个字符为止。
 1 /*************************************************************************
 2     > File Name: g.cpp
 3     > Author: Nature
 4     > Mail: 564374850@qq.com
 5     > Created Time: Wed 30 Jul 2014 08:35:57 PM CST
 6 ************************************************************************/
 7 
 8 #include <cstdio>
 9 #include <cstring>
10 #include <cstdlib>
11 #include <cmath>
12 #include <iostream>
13 #include <algorithm>
14 using namespace std;
15 
16 int n;
17 char s[10005];
18 
19 int Solve(int x,int y){
20     if(x > y)
21         return 4;
22     if(x == y && s[x] == 'A')
23         return 1;
24     //simple
25     if(y > 0 && s[y - 1] == 'A' && s[y] == 'B' && Solve(x,y - 2) != 4)
26         return 2;
27     else if(s[x] == 'B' && s[y] == 'A' && Solve(x + 1,y - 1) != 4)
28         return 3;
29     return 4;
30 }
31 
32 int main(){
33     scanf("%d",&n);
34     while(n--){
35         scanf("%s",s);
36         int len = strlen(s);
37         int ans = Solve(0,len - 1);
38         if(ans == 1)
39             printf("SIMPLE\n");
40         else if(ans == 2)
41             printf("FULLY-GROWN\n");
42         else if(ans == 3)
43             printf("MUTAGENIC\n");
44         else
45             printf("MUTANT\n");
46     }
47     return 0;
48 }

 

 

转载于:https://www.cnblogs.com/naturepengchen/articles/3887128.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值