시간 제한메모리 제한제출정답맞힌 사람정답 비율
0.1 초 1024 MB2011106852.308%

문제

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.

예제 입력 1

3
OF
BOB
BEWARE

예제 출력 1

Y

예제 입력 2

3
WHO
MADE
WHO

예제 출력 2

N

예제 입력 3

5
JUST
USE
WORD
XX
TWICE

예제 출력 3

Y

예제 입력 4

1
YYYYYYYYYYY

예제 출력 4

Y

출처

ICPC > Regionals > Latin America > Latin America Regional Contests > Latin America Regional Contests 2021 K번

  • 문제를 만든 사람: Alejandro Strejilevich de Loma