DMOPC '18 Contest 6 P1 - DNA or RNA?

View as PDF

Submit solution


Points: 3
Time limit: 2.0s
Memory limit: 64M

Author:
Problem type

Deoxyribonucleic acid (DNA) and ribonucleic acid (RNA) are both molecules used for storing genetic code, and both consist of a number of bases connected in a line. A DNA or RNA molecule can be represented as a string of uppercase English letters, each letter representing a base.

Each base in a DNA or RNA molecule must be one of the following: adenine (A), cytosine (C), guanine (G), thymine (T), or uracil (U). Thymine is found only in DNA, while uracil is found only in RNA. Adenine, cytosine, and guanine can be present in both DNA and RNA.

Dr. Henri is studying a molecule consisting of N bases. He wants to know if it could be DNA, RNA, or something completely new!

Constraints

1N1000000

Input Specification

The first line contains N.
The second line contains N characters with no spaces, representing the bases of the molecule. All of the characters are uppercase English letters.

Output Specification

Output DNA if the molecule could be DNA only, RNA if it could be RNA only, both if it could be either, and neither if it could not be RNA or DNA.

Sample Input 1

Copy
6
ACTAGC

Sample Output 1

Copy
DNA

Sample Input 2

Copy
6
GCAAGG

Sample Output 2

Copy
both

Sample Input 3

Copy
6
NLOPEJ

Sample Output 3

Copy
neither

Comments

There are no comments at the moment.