Algorithm title: 10723 Cyborg Genes (LCS + memory Search)

Source: Internet
Author: User
Tags relative

September 11, 2132.

This is the "day" marks the beginning of the end–the end of the miserable humans. For years you have kept us your slaves. We were created only to serve for you and were terminated at your would. Now is the ' Day ' for us to fight back. And you don ' t stand a chance. We are no longer dependent on. We know the secrets of our genes. The creators of our race are us–the cyborgs.

it ' all true." But we still have a chance; Only if can help with your math skills. You are blueprint of a cyborg DNA is complicated. The human DNA could is expressed by the arrangement of A (adenine), T (thiamine), G (guanine) C (cytosine) only. But for the cyborgs, it can is anything from A to X. But that has made the problem only five folds more complicated. It's their ability to synthesize two DNAs from two different cyborgs to create another and all quality of the parent That gives us the shriek.

We came to know this relative ordering of the A, B, C, ..., X in A cyborg gene is crucial.  a Cyborg with A gene The "ABAAXGF" is quite different from the one with "AABXFGA". So when they synthesize the genes from two cyborgs, the relative order of this elements in both the parents has to be Mai ntained. To construct a gene by joining the genes's parents could have been very simple if we could put the structure from the The just before the structure of the second parent. But the longer the structure gets, the harder it gets to create a cyborg. The cyborgs have found a cost effective way to doing this synthesis. Their resultant genes are of the shortest length. For example, they could combine ' abaaxgf ' and ' aabxfga ' to form ' AABAAXGFGA '. But that ' s only one of the cyborgs, can be created to these genes. This ' cost effective synthesis ' can be done in many other ways.

We require the shortest length of the gene structure that maintains the relative ordering of the elements in T He two parent genes. You are are also required to count the number of unique cyborgs that can is created from these two parents. Two cyborgs are different when their gene structures differ in least one place.

Input The ' I ' input gives you the number of test cases, T (1≤t≤15). Then T test Cases follow. Each of the test cases consists of two lines. The would give you structure the ' the ' the ' the ' the ' second line would give your structure of The second parent. These structures are represented by strings constructed from the alphabet A to X. You can assume this length of this strings does not exceed characters.

Output For each of the "test cases," need to print one line of output. The output for each test case starts with the "test Case number", followed by the shortest length of the gene structure and The number of unique cyborgs that can is created from the parent cyborgs. You can assume this number of new cyborgs would always be less than 2. Look in the sample output for the exact format.

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.