LCC/Moose '19 Contest 5 S1 - Genome

View as PDF

Submit solution

Points: 5 (partial)
Time limit: 2.0s
Memory limit: 128M

Author:
Problem type

As part of the global effort to combat COVID-19, scientists are sequencing the genome of many samples that they find. Using this information, it is possible to trace how the virus evolves and how it spread, as well as helps in finding a cure.

As a simple model, the virus's genome can be represented by a string consisting of the letters A, T, C, G. The difference between two strains X and Y is equal to the number of positions in which their genomes differ. A strain of the virus Z is to be an ancestor of X and Y if both the difference between X and Z and the difference between Y and Z is strictly smaller than the difference between X and Y.

Given three sequences, determine if one of them is an ancestor of the other two.

Input Specification

The input begins contains three strings X, Y, Z, the three sequences. All three strings are the same length of less than or equal to 100 characters.

Output Specification

Output one of the strings if it is an ancestor of the other two; or Unrelated otherwise.

Sample Input 1

ACTG
CCTG
CCTA

Sample Output 1

CCTG

Sample Input 2

ACTG
ATCG
CTTG

Sample Output 2

Unrelated

Comments

There are no comments at the moment.