ECOO '21 P2 - DNA Derren

View as PDF

Submit solution

Points: 3 (partial)
Time limit: 2.0s
Memory limit: 256M

Problem type

One day Derren decided he would do something remarkable with his life. Since Derren is very ambitious, he has decided he wants to memorize his own DNA genome sequence. The only problem is that the human genome is too long to be memorized letter-by-letter.

In order to help him, you offered to write a program to divide his genome into the least number of words. He tells you that each of these words must be distinctly pronounceable. For a word to be considered distinctly pronounceable, the word must either be one letter in length or each pair of two adjacent letters in a word must contain a vowel and a consonant.

Can you write a program to help Derren memorize his DNA genome?

Input Specification

A single line, the DNA sequence that Derren wants to memorize. The length of the line will contain at least 1 character and will not exceed 10^5 characters in length. The line will only consist of the characters A, C, T and G.

For 70\% of the points, the length of the line will not exceed 100 characters in length.

Output Specification

A single line, the input line with spaces inserted in the best positions to help Derren memorize his DNA Sequence.

Sample Input 1

ACTGAGCA

Sample Output 1

AC T GAG CA

Sample Explanation 1

AC is a two letter word containing a vowel and a consonant.

T is a one letter word. It is separated because the pair CT and TG both would lack a vowel.

GAG is one word because the GA and AG pairs both contain a vowel.

There is a space between GAG and CA since the GC pair lacks a vowel.

CA is a two letter word containing a vowel and a consonant.

Sample Input 2

AAAAGCGCTA

Sample Output 2

A A A AG C G C TA

Comments

There are no comments at the moment.