Programming contests

DEIK Regionális Programozó Csapatverseny, egyetemi/főiskolai kategória, 2012. november 25.

November 25, 2012 11:30 AM – November 25, 2012 4:30 PM

Chemist's Vows

Chemist Clara swore a solemn vow—from now on, she can only speak atomic element symbols. Of course, this limits her ability to talk. She can say, for example, “I Am CLaRa” (as I is the symbol of iodine, Am is americium, C is carbon, and so on). She can also say “InTeRnAtIONAl”, but she has a lot of trouble with “collegiate”, “programming”, and “contest”.

Given a word, determine whether Clara can speak it (i.e., if it is a concatenation of atomic symbols). Without your help, she might as well have taken silence vows!

You may identify upper- and lowercase letters, as Clara cannot speak uppercase anyway. In case you forgot the elements' symbols, here is the complete periodic table:

H                                                                   He
Li  Be                                          B   C   N   O   F   Ne
Na  Mg                                          Al  Si  P   S   Cl  Ar
K   Ca  Sc  Ti  V   Cr  Mn  Fe  Co  Ni  Cu  Zn  Ga  Ge  As  Se  Br  Kr
Rb  Sr  Y   Zr  Nb  Mo  Tc  Ru  Rh  Pd  Ag  Cd  In  Sn  Sb  Te  I   Xe
Cs  Ba  *   Hf  Ta  W   Re  Os  Ir  Pt  Au  Hg  Tl  Pb  Bi  Po  At  Rn
Fr  Ra  **  Rf  Db  Sg  Bh  Hs  Mt  Ds  Rg  Cn      Fl      Lv

*   La  Ce  Pr  Nd  Pm  Sm  Eu  Gd  Tb  Dy  Ho  Er  Tm  Yb  Lu
**  Ac  Th  Pa  U   Np  Pu  Am  Cm  Bk  Cf  Es  Fm  Md  No  Lr

Input Specification

The first line of the input contains the number of test cases T. The descriptions of the test cases follow:

Each test case is a single lowercase word over the English alphabet. The length of the word is positive and does not exceed 50000.

Output Specification

Print the answers to the test cases in the order in which they appear in the input. For each test case, print a single line containing the word “YES” if Clara can say the given word, and “NO” otherwise.

Sample Input

  1. 4
  2. international
  3. collegiate
  4. progamming
  5. contest
download as text file

Output for Sample Input

  1. YES
  2. NO
  3. NO
  4. NO
download as text file
University of Debrecen; Faculty of Informatics; v. 03/01/2019