QOJ.ac

QOJ

実行時間制限: 1 s メモリ制限: 1024 MB 満点: 100

#2748. 迷失即是接近失败

統計

Better Documents Inc. 正在构思下一代文字处理器。如今,几乎每个文字处理器都包含拼写检查功能。然而,BDI 希望用真正的“错别字检查器”来取代它。我们都有过这样的经历:依赖拼写检查器时,因为打字错误(“typos”)导致输入了一个拼写正确的词,但却不是我们原本想要的那个词。BDI 希望利用人工智能来判断一个词的上下文是否暗示它用错了,而原本应该是一个拼写相似的词。

作为该过程的第一步,他们想看看在普通文本中这种相似词出现的频率有多高。请编写一个程序,读取文本段落并生成该文本中出现的相似拼写词列表。

在本程序中,一个“词”(word)是指任何包含至少一个字母字符的非空白字符的最大字符串。空白字符可以是空格或行终止符(“\r”或“\n”)。一个词的“核心”(core)是指去掉所有非字母字符并将所有大写字母替换为对应小写字母后剩下的部分。

如果一个词的核心可以通过以下任一变换操作一次转换为另一个词的核心,则称这两个词为“拼写相似”:

  • 删除单个字符。
  • 插入单个字母字符。
  • 将单个字符替换为不同的字母字符。
  • 交换任意两个相邻字符。

输入格式

输入包含 1 到 100 行文本,随后是一个以仅包含字符串 *** 的行作为结束的标记。

每行文本包含 0 到 80 个 ASCII 字符(不计行终止符)。

输出格式

对于文本中拥有 1 个或多个拼写相似词的每个词核心,打印一行,包含:

  1. 该词核心。
  2. 一个冒号(:)后跟一个空格。
  3. 所有拼写相似的词核心列表(无重复,且不包含冒号左侧的词核心本身),按字母顺序排列,并以单个空格分隔。

打印的行应按冒号左侧词核心的字母顺序排列。

如果输入中没有拼写相似的词,则打印一行包含字符串 ***

样例

输入格式 1

Lost is Close to Lose
"Better Documents Inc. wants to add Typo Checking in to the
next generation of word processors," he said.
***

输出格式 1

close: lose
he: the
in: inc is
inc: in
is: in
lose: close lost
lost: lose
the: he

输入格式 2

The fox said, "When?"
"Not till 12 o’clock", replied the hen.
"That clock is stopped, it will never strike.", he said.
***

输出格式 2

clock: oclock
he: hen the
hen: he when
is: it
it: is
oclock: clock
the: he
till: will
when: hen
will: till

输入格式 3

There are no similar words
in this input set.
***

输出格式 3

***

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.