QOJ.ac

QOJ

Limite de temps : 5 s Limite de mémoire : 1024 MB Points totaux : 100

#5343. Joe 正在学习说话

Statistiques

Joe 是一个 4 岁的孩子,正在学习他的母语。他曾试图记住语言中所有可能的句子,但很快意识到句子的数量是无限的。于是他决定专注于记忆长度不超过 $n$ 的子序列及其含义。如果 Joe 已经记住了某个句子的所有长度不超过 $n$ 的子序列,他就认为自己理解了这个句子。

每天下午,Joe 开始逐一阅读句子。他记得过去几天学到的所有内容。读完一个句子后,他会询问每一个他不认识的单词并学习它。如果他不能完全理解这个句子,他会询问整个句子的含义。在此之后,他会记住该句子中所有长度不超过 $n$ 的子序列,然后阅读下一个句子。

例如:假设 Joe 只记忆长度为 1 或 2 个单词的子序列,并且他已经知道了句子 “I live in a house” 和 “This is a green house”。他将完全理解句子 “I live in a green house”,因为他已经知道了所有长度为 1 和 2 的子序列。然而,如果他决定记忆长度不超过 3 的子序列,他会询问整个句子的含义,因为 “in a green” 在之前的任何句子中都不是长度为 3 的子序列。显然,Joe 总是知道他自己的名字。

输入格式

输入包含多个测试用例,每个测试用例以一行表示 Joe 可以记忆的最大长度 $n$ ($2 \le n \le 5$) 开始。

接下来的行包含 Joe 在过去几天中已经记住的知识(句子)。字符 * 表示先前知识的结束。在 * 之后,是包含 Joe 今天要学习的若干句子的文本。符号 # 表示 Joe 今天要阅读的句子结束。

这两个部分最多包含 20000 个不同的单词。句子由输入中作为独立标记出现的以下字符分隔:. , : ; ? !

每个单词的长度最多为 20。每个句子的最大单词数为 100。每个部分的句子最大数量为 1000。句子可能会重复出现。

所有单词仅包含罗马字母,除了句子分隔符外,不使用数字或其他符号。仅大小写不同的单词被视为同一个单词。例如:Joe, JOE 和 joE 代表同一个单词。

输出格式

对于每个测试用例,输出一行文本 Learning case C,其中 $C$ 是从 1 开始的用例编号。不同测试用例的输出应以空行分隔。

对于每一个未知的单词 $W$,他会询问含义,格式为:What does the word "W" mean?。对于每一个 Joe 不理解的句子 $S$,他会询问:What does the sentence "S" mean?。输出 $W$ 和 $S$ 时,应保持它们在输入中出现时的大小写。$S$ 中的单词必须用恰好 1 个空格分隔。

样例

样例输入 1

2
hello sam . say hello to everybody . good bye .
*
say hi to everybody .
hi to everybody .
hello joe .
swerc
#
4
Joe is my name . I have a dog . My dog is
a
cinnamon coloured golden retriever
. The name of my father is Ben and the name
of my mother is Linda .
*
Hello Joe , how are you ? Are you my friend ?
Last day you told me : the name of my mother is Linda .
You also told me : the name of my father is Ben .
How are you my friend ?
#

样例输出 1

Learning case 1
What does the word "hi" mean?
What does the sentence "say hi to everybody" mean?
What does the sentence "hello joe" mean?
What does the word "swerc" mean?

Learning case 2
What does the word "Hello" mean?
What does the sentence "Hello Joe" mean?
What does the word "how" mean?
What does the word "are" mean?
What does the word "you" mean?
What does the sentence "how are you" mean?
What does the word "friend" mean?
What does the sentence "Are you my friend" mean?
What does the word "Last" mean?
What does the word "day" mean?
What does the word "told" mean?
What does the word "me" mean?
What does the sentence "Last day you told me" mean?
What does the word "also" mean?
What does the sentence "You also told me" mean?
What does the sentence "How are you my friend" mean?

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.