The 7th(2012) ACM Programming Contest of HUST - Preliminary Contest
From: 2012-11-17 12:00:00
To: 2012-11-17 17:00:00
Now: 2017-09-22 06:51:01
F - Gene recombination
Time Limit: 2s
Memory Limit: 64MB
Submissions: 364 Solved: 83
- 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". And he wants to reorder this gene to make a new one, like "CTCA". He can use two types of operations: (1) exchange the first two letters, or (2) move the first letter to the end of the gene. For example, "ATCC" can be changed to "TCCA" by operation (2), and then "TCCA" can be changed to "CTCA" by operation (1). 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.
Note that the two strings have the same number for each kind of letter.
- For each test case, output the minimum number of operations.
- Sample Input
- Sample Output
- Problem Setter : Jian He