Programming contests

ACM ICPC programozó csapatverseny, házi forduló, 2013. október 20.

October 20, 2013 10:10 AM – October 20, 2013 3:10 PM

Flowers Flourish from France

Fiona has always loved poetry, and recently she discovered a fascinating poetical form. Tautograms are a special case of alliteration, which is the occurrence of the same letter at the beginning of adjacent words. In particular, a sentence is a tautogram if all of its words start with the same letter.

For instance, the following sentences are tautograms:

  • Flowers Flourish from France
  • Sam Simmonds speaks softly
  • Peter pIckEd pePPers
  • truly tautograms triumph

Fiona wants to dazzle her boyfriend with a romantic letter full of this kind of sentences. Please help Fiona to check if each sentence she wrote down is a tautogram or not.

Input Specification

Each test case is given in a single line that contains a sentence. A sentence consists of a sequence of at most 50 words separated by single spaces. A word is a sequence of at most 20 contiguous uppercase and lowercase letters from the English alphabet. A word contains at least one letter and a sentence contains at least one word.

The last test case is followed by a line containing only a single character “*” (asterisk).

Output Specification

For each test case, output a single line containing an uppercase “Y” if the sentence is a tautogram, or an uppercase “N” otherwise.

Sample Input

  1. Flowers Flourish from France
  2. Sam Simmonds speaks softly
  3. Peter pIckEd pePPers
  4. truly tautograms triumph
  5. this is NOT a tautogram
  6. *
download as text file

Output for Sample Input

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