아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

KIARA is a Recursive Acronym

시간 제한0.1초메모리 제한1024 MB

요약
대문자 단어 목록이 주어질 때, 어떤 단어의 각 글자를 목록에 있는 단어의 첫 글자로 하나씩 대응시킬 수 있는지 판별한다.
난이도

보통10점 중 5점

유형
문자열, 완전 탐색, 구현, 수학
정답자
아직 제출이 없습니다

문제

A recursive acronym is an acronym in which one of its letters stands for the acronym itself. For instance, the first word in the title of this problem is a recursive acronym of the full title. Another example is “BOB”, which is an acronym of “Beware of Bob”.

Given a list of words, you must decide whether there exists a word in the list which is a recursive acronym of a phrase that can be formed using words in the list. Since the first letter of any word can stand for the whole word, it is enough to decide whether there exists a word in the list which can be formed using the first letter of some words in the list.

입력

The first line contains a positive integer N indicating the number of words in the list. Each of the next N lines contains a non-empty string made of uppercase letters representing a word in the list. The sum of the lengths of all the strings is at most 106.

출력

Output a single line with the uppercase letter “Y” if there exists a word in the list which is a recursive acronym of a phrase that can be formed using words in the list, and the uppercase letter “N” otherwise.

예제4

  1. 예제 1

    입력
    3
    OF
    BOB
    BEWARE
    
    예상 출력
    Y
    
  2. 예제 2

    입력
    3
    WHO
    MADE
    WHO
    
    예상 출력
    N
    
  3. 예제 3

    입력
    5
    JUST
    USE
    WORD
    XX
    TWICE
    
    예상 출력
    Y
    
  4. 예제 4

    입력
    1
    YYYYYYYYYYY
    
    예상 출력
    Y