QOJ.ac

QOJ

حد الوقت: 2 s حد الذاكرة: 512 MB مجموع النقاط: 100

#2141. 命运之轮

الإحصائيات

Katya 终于实现了她参加“幸运之轮”(Wheel of Fortune)游戏的夙愿。

让我们回顾一下“幸运之轮”游戏的规则:

  • 游戏的目标是猜出主持人隐藏的一个单词。参赛者轮流说出一个字母。
  • 如果所说的字母出现在隐藏单词中,主持人会揭示该单词中所有该字母的位置,并且该参赛者可以继续说出一个新的字母。
  • 如果参赛者说的字母没有出现在隐藏单词中,则轮到下一位参赛者。

主持人隐藏了一个长度为 $L$ 的单词。Katya 非常想赢得比赛,于是她入侵了游戏编辑的电脑。她发现隐藏的单词将是 $N$ 个单词中的某一个。

Katya 在游戏中拥有第一轮机会。请帮助 Katya 判断她是否能保证赢得比赛。也就是说,Katya 是否能在不失去轮次的情况下猜出列表中的任意一个单词?

输入格式

第一行包含两个整数 $L$ 和 $N$ —— 隐藏单词的长度和候选单词的数量($1 \le L \le 10^6$,$1 \le N \le 10^5$)。

接下来的 $N$ 行包含 $N$ 个长度为 $L$ 的不同单词。这些单词由小写英文字母组成。

保证所有单词的总长度不超过 $10^6$。

输出格式

如果 Katya 能保证自己获胜,输出“YES”,否则输出“NO”。

样例

样例输入 1

5 2
hello
world

样例输出 1

YES

样例输入 2

4 4
idea
play
game
warm

样例输出 2

YES

样例输入 3

4 2
game
name

样例输出 3

NO

说明

在第一个样例中,如果 Katya 首先说出字母“l”,通过观察揭示出的字母,她就能确定隐藏的单词。

在第三个样例中,对于 Katya 的所有策略,都存在说错字母并失去轮次的风险。

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
EditorialOpen Official EditorialQingyu- Download

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.