TopCoder problem "Find3Cheaters" used in TCO04 Round 1 (Division I Level Three)



Problem Statement

    You have recently collected a programming assignment from your class, and suspect some people have cheated. An anonymous informant has let you know that the cheaters work in groups of 3. To quickly find the cheaters, you want a program that will find the shortest common supersequence of 3 different assignments. Three assignments will be given to you in three Strings a, b, and c. Return the length of the shortest common supersequence of these 3 Strings.



Given a String X, a subsequence of X is a String produced by removing some of the characters of X (possibly none). For example, (quotes for clarity) "topcoder", "toder", "oode", and "" are all subsequences of "topcoder". If Y is a subsequence of X then X is a supersequence of Y.
 

Definition

    
Class:Find3Cheaters
Method:shortest
Parameters:String, String, String
Returns:int
Method signature:int shortest(String a, String b, String c)
(be sure your method is public)
    
 

Constraints

-a will contain between 1 and 50 lowercase letters ('a'-'z') inclusive.
-b will contain between 1 and 50 lowercase letters ('a'-'z') inclusive.
-c will contain between 1 and 50 lowercase letters ('a'-'z') inclusive.
 

Examples

0)
    
"aagaaa"
"ataatg"
"ctggg"
Returns: 11
"catagagaatg" is a supersequence of all 3 strings.
1)
    
"wowwowwow"
"wowwowwow"
"badbadbad"
Returns: 18
"wowwowwowbadbadbad" is a supersequence of all 3.
2)
    
"a"
"aaaaaaa"
"aaaaaaaaaaaaaa"
Returns: 14

Problem url:

http://www.topcoder.com/stat?c=problem_statement&pm=1998

Problem stats url:

http://www.topcoder.com/tc?module=ProblemDetail&rd=5878&pm=1998

Writer:

AdminBrett

Testers:

PabloGilberto , lbackstrom

Problem categories:

Dynamic Programming, String Manipulation