uva 620 Cellular Structure (水题)

本文介绍了一种用于识别细胞分裂阶段的算法,包括简单阶段、完全生长阶段和突变阶段。算法通过输入细胞链序列,输出相应的细胞分裂阶段类型。适用于生物科学研究中的细胞周期分析。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

uva 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 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)在空的情况下,生成A—>SIMPLE;
2)在不空的情况下,在两边生成B 和 A–>MUTAGENIC;
3)在不空的情况下,在右边生成AB–>FULLY-GROWN;
当三种情况都不满足输出 MUTANT。
题目要求求出最后一种分裂方式。
解题思路:先判断字符串的长度:为1时,输出SIMPLE;为偶数时,输出MUTANT;为奇数时,从后往前遍历,若当前字母为B判断FULLY-GROWN方法,为A时判断MUTAGENIC方法,判断不满足跳出循环输出MUTANT。从后往前遍历到的第一种方法就是酒后一种分裂方式。
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#define N 10005
using 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;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值