Recursive uva-620-Cellular Structure

Source: Internet
Author: User

There are three cases of normal cell classification. 1. simple stage OA // O represents the healthy cell classification form, which indicates that the simple stage is in progress. 2. fully-grown stage OAB // O represents the healthy cellular classification form, which indicates that the fully-grown stage is in progress. 3. mutagenic stage BOA // O represents the healthy cellular classification form, which indicates that the mutagenic stage is in progress. Give a sequence for you to find the stage in progress of the current cell. If it is not the first three cases, it indicates that the cell has changed, then the output mutation stage. If there are two stages at the same time, the output is ranked at the top in the above Order. Solution: test the current sequence in sequence based on the above three stages. If none of the above conditions are met, it indicates that the cell has changed. Code: [cpp] # include <iostream> # include <cmath> # include <cstdio> # include <cstdlib> # include <string> # include <cstring> # include <algorithm> # include <vector> # include <map> # include <stack> # include <queue> # define eps 1e-6 # define INF (1 <20) # define PI acos (-1.0) using namespace std; char save [1200]; int dfs (int begin, int end) // 1 indicates the first type, 2 indicates the second type, 3 indicates the third type, and 0 indicates other types {if (begin = end & save [begin] = 'A ') // if there is only one A, return 1 is in the first stage; if (end-begin> = 1 & save [end] = 'A' & dfs (begin, end-1) // determine whether the first stage return 1 is satisfied; if (end-begin> = 2 & save [end] = 'B' & save [end-1] = 'A' & dfs (begin, end-2) // determine whether the second-stage return 2 is satisfied; if (end-begin> = 2 & save [begin] = 'B' & save [end] = 'A' & dfs (begin + 1, end-1) // determines whether the return 3; return 0;} int main () {int n; scanf ("% d", & n ); while (n --) {scanf ("% s", save); int len = strlen (save); int ans = dfs (0, len-1); switch (ans) {case 0: printf ("MUTANT \ n"); break; case 1: printf ("SIMPLE \ n"); break; case 2: printf ("FULLY-GROWN \ n"); break; case 3: printf ("MUTAGENIC \ n"); break ;};} return 0 ;}

Related Article

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.