Programming contests

ECN programozó csapatverseny, 2022. május 28.

May 28, 2022 10:15 AM – May 28, 2022 3:15 PM

To Marry or Not to Marry?

Landia country is strict about its marriage policy, allowing only couples with genes that are quite different to marry. To avoid diseases, the similarity of their genes should not exceed 80%. Doctors take samples and process them, i.e., convert the DNA sequences to amino acids. The sample can be corrupted; it must be checked if it was collected correctly: the DNA sequence can be converted to amino acids. A DNA sequence is correct if it only contains the 4 nucleotides (letters): A, G, T, and C. The sequence must begin with the Methionine (Met in the table) amino acid. Nucleotides can be converted to amino acids without residue and there must be only one stop signal in the sequence at the end of it. The DNA is transformed as follows: 3 nucleotides are converted to one amino acid according to the following table:

Determine how similar the chains of the two amino acids are. If they are similar in more than 80%, the program should output “Forbidden”, otherwise “Allowed”. In case of incorrect input, the program should warn us with the following message: “Incorrect input”.

The similarity of two chains of amino acids means how many amino acids need to be replaced, deleted, or added to convert one into the other. That is, the similarity is the ratio of the number of steps to the length of the longer sequence, excluding the first and last amino acids:

Input Specification

The input contains two lines in varying lengths (between 0 and 120), the DNA sequences. The DNA sequences aren't necessarily the same length.

Output Specification

Print one line to the standard output, containing one of “Forbidden”, “Allowed”, and “Incorrect input”, as specified above.

Sample Input 1

download as text file

Output for Sample Input 1

  1. Allowed
download as text file

Sample Input 2

download as text file

Output for Sample Input 2

  1. Incorrect input
download as text file

Sample Input 3

download as text file

Output for Sample Input 3

  1. Forbidden
download as text file
University of Debrecen; Faculty of Informatics; v. 03/01/2019