QOJ.ac

QOJ

Límite de tiempo: 3 s Límite de memoria: 512 MB Puntuación total: 100

#3671. 电子邮件销毁

Estadísticas

你在 ICPCorrespondence.com 有一个账户。这是一项电子邮件服务,邮件按主题分组为链,规则如下:

链中的第一封邮件有一个由小写英文字母组成的非空主题。链中后续的每一封邮件的主题都由 “Re: ” 加上前一封邮件的主题组成。

例如,如果链中的第一封邮件主题为 “subj”,那么第二封邮件的主题为 “Re: subj”,第三封邮件的主题为 “Re: Re: subj”,依此类推。形式上,链中第 $k$ 封邮件的主题由 “Re: ” 重复 $k-1$ 次,后接链中第一封邮件的主题组成。

在攻击发生前,你的邮箱中有一条或多条主题唯一的邮件链。你从未从邮箱中删除过任何邮件。

不幸的是,有一天 ICPCorrespondence.com 遭到了黑客攻击。攻击导致服务器上的一些邮件被删除,而剩余的邮件顺序被打乱了。

你不确定攻击前邮箱里有多少封邮件,但你猜测这个数字是 $n$。请检查你的这个猜测是否可能是正确的。

输入格式

输入的第一行包含两个整数 $n$ 和 $k$,分别表示你猜测攻击前邮箱中的邮件总数,以及攻击后剩余的邮件数量 ($1 \le k \le n \le 100$)。

接下来的 $k$ 行包含攻击后留在你邮箱中的邮件主题,每行一个。每封邮件的主题由 “Re: ” 重复零次或多次,后接至少 1 个且不超过 10 个小写英文字母组成。每个主题的长度不超过 500。所有邮件主题各不相同。

输出格式

如果关于攻击前邮箱中邮件总数的猜测可能是正确的,输出单词 “YES”。否则,输出单词 “NO”。

样例

样例输入 1

7 3
Re: Re: Re: hello
Re: world
hello

样例输出 1

YES

样例输入 2

3 2
Re: Re: pleasehelp
me

样例输出 2

NO

说明

在第一个样例中,猜测可能是正确的。例如,你可能拥有主题为 “hello”、“Re: hello”、“Re: Re: hello”、“Re: Re: Re: hello”、“Re: Re: Re: Re: hello”、“world” 和 “Re: world” 的邮件。

在第二个样例中,猜测是不正确的,因为 “pleasehelp” 链中至少需要有三封邮件,而 “me” 链中至少需要有一封邮件。

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.