Ultraviolet A 620 Cellular Structure (water question)

Source: Internet
Author: User

Ultraviolet A 620 Cellular Structure (water question)
Ultraviolet A 620 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 wocould take one of the following forms:

? Simple stage O = ? 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 wocould end up also with a chain of a healthy organism. it wocould grow by one cell.

A laboratory researches a cluster of these organisms. Your task is to write a program which cocould 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 shocould be given as an answer.

Sample Input

4
A
AAB
BAAB
BAABA

Sample Output

SIMPLE
FULLY-GROWN
MUTANT
MUTAGENIC

There are three ways to split: 1) generate A-> SIMPLE when there is no blank; 2) generate B and A-> MUTAGENIC on both sides if there is no blank; 3) if it is not empty, generate AB-> FULLY-GROWN on the right side. In none of the three cases, the output MUTANT is not satisfied. The question requires finding the last split method. Solution: first judge the length of the string: when it is 1, the output is SIMPLE; when it is an even number, the output MUTANT; when it is an odd number, traverse from the back to the front, if the current letter is B, the FULLY-GROWN method is used to determine the MUTAGENIC method when it is A, and the result of MUTANT output is not satisfied. The first way to traverse from the back to the front is to split the wine.
#include 
  
   #include 
   
    #include #include 
    
     #include 
     
      #define N 10005using namespace std;typedef long long ll;char s[N];int main() {    int T;    scanf("%d", &T);        while (T--) {        scanf("%s", s);        int len = strlen(s);        if (len == 1) {            printf("SIMPLE\n");            continue;        }        else if (len % 2 == 0) {            printf("MUTANT\n");            continue;        }        int flag = 1;        int first = 0, last = len - 1;        while (first != last) {            if (s[last] == 'B') {                if (s[last - 1] != 'A') {                    flag = 0;                    break;                }                else {                    if (flag == 1) flag = 2;                    last -= 2;                }            } else if (s[last] == 'A') {                if (s[first] != 'B') {                    flag = 0;                    break;                }                else {                    if (flag == 1) flag = 3;                    last--;                    first++;                }            }        }        if (flag == 1 || flag == 0) printf("MUTANT\n");        else if (flag == 2) printf("FULLY-GROWN\n");        else if (flag == 3) printf("MUTAGENIC\n");    }    return 0;}
     
    
   
  

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.