QOJ.ac

QOJ

時間限制: 0.5 s 記憶體限制: 2048 MB 總分: 100

#3591. KIARA 是一个递归缩写

统计

递归缩写(recursive acronym)是指其中一个字母代表缩写本身的首字母缩写。例如,本题标题中的第一个单词就是完整标题的递归缩写。另一个例子是“BOB”,它是“Beware of Bob”的缩写。

给定一个单词列表,你需要判断列表中是否存在一个单词,它是通过列表中单词组成的短语的递归缩写。由于任何单词的首字母都可以代表整个单词,因此只需判断列表中是否存在一个单词,该单词可以由列表中某些单词的首字母组成。

输入格式

第一行包含一个正整数 $N$,表示列表中的单词数量。接下来的 $N$ 行,每行包含一个由大写字母组成的非空字符串,表示列表中的一个单词。所有字符串的长度之和最多为 $10^6$。

输出格式

如果列表中存在一个单词是列表中单词所组成短语的递归缩写,则输出一行大写字母“Y”,否则输出大写字母“N”。

样例

样例输入 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

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.