21619_GeneReprogra

2022-5-16 18:19| 发布者: Hocassian| 查看: 23| 评论: 0|原作者: 肇庆学院ACM合集

摘要:
C:\Users\Administrator\Downloads\2019-10-12-10-14-4-89505695547700-Problem List-采集的数据-后羿采集器.html

Pro.ID

21619

Title

Gene Reprogram

Title链接

http://10.20.2.8/oj/exercise/problem?problem_id=21619

AC

0

Submit

0

Ratio

-

时间&空间限制

  • Time Limit: 2000/1000 MS (Java/Others)     Memory Limit: 65536/65536 K (Java/Others)
  • 描述

    As a gene engineer of a gene engineering project, Enigma encountered a puzzle about gene recombination.

    It is well known that a gene can be considered as a sequence, consisting of four nucleotides, which are simply denoted by four letters, A, C, G, and T.

    Enigma has gotten a gene, such as "ATCC" for example. And he wants to reorder this gene to a new one, "CTCA" for instance. He can use two kinds of operations: (1) exchange the first two letters, or (2) move the first letter to end of the gene. For example, "ATCC" can be changed to "TCCA" by operation two, and then "TCCA" can be changed to "CTCA" by operation one. Your task is to make a program to help Enigma to find out the minimum number of operations to reorder the gene.

    输入

    The input contains several test cases. The first line of a test case contains one integer N indicating the length of the gene ( 1 ≤ N ≤ 12 ). The second line contains a string indicating the initial gene. The third line contains another string which Enigma wants.

    For each kind of letter, the two strings have the same number of it. Input is terminated by one line contains one zero.

    输出

    Description

    As a gene engineer of a gene engineering project, Enigma encountered a puzzle about gene recombination.

    It is well known that a gene can be considered as a sequence, consisting of four nucleotides, which are simply denoted by four letters, A, C, G, and T.

    Enigma has gotten a gene, such as "ATCC" for example. And he wants to reorder this gene to a new one, "CTCA" for instance. He can use two kinds of operations: (1) exchange the first two letters, or (2) move the first letter to end of the gene. For example, "ATCC" can be changed to "TCCA" by operation two, and then "TCCA" can be changed to "CTCA" by operation one. Your task is to make a program to help Enigma to find out the minimum number of operations to reorder the gene.

    Input

    The input contains several test cases. The first line of a test case contains one integer N indicating the length of the gene ( 1 ≤ N ≤ 12 ). The second line contains a string indicating the initial gene. The third line contains another string which Enigma wants.

    For each kind of letter, the two strings have the same number of it. Input is terminated by one line contains one zero.

    Output

    For each test case, output the minimum number of operations.

    Sample Input

    4
    ATCC
    CTCA
    4
    ATCG
    GCTA
    4
    ATCG
    TAGC
    0

    Sample Output

    2
    4
    6

    Source

    样例输入

    4
    ATCC
    CTCA
    4
    ATCG
    GCTA
    4
    ATCG
    TAGC
    0

    样例输出

    2
    4
    6

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部