Searching Quickly
题意翻译
# 问题
给定一组称呼和一组“忽略单词”,你要写一个程序为该列表生成KWIC索引。在KWIC索引中,对于每个关键字,含有该关键字的称呼都要出现一次。KWIC索引按关键字的字母表顺序排列。
没有在“忽略单词”中出现的任何单词都可能是关键字。
比方说,“the, of, and, as, a”是忽略单词表,下面是称呼列表:
Descent of Man
The Ascent of Man
The Old Man and The Sea
A Portrait of The Artist As a Young Man
A KWIC-index of these titles might be given by:
那么这些称呼的KWIC索引就应该是(中间对齐的大写单词指出其关键字):
a portrait of the
ARTIST as a young man
the
ASCENT of man
DESCENT of man
descent of
MAN
the ascent of
MAN
the old
MAN and the sea
a portrait of the artist as a young
MAN
the
OLD man and the sea
a
PORTRAIT of the artist as a young man
the old man and the
SEA
a portrait of the artist as a
YOUNG man
## 输入
输入由很多行组成,字符串“::”作为忽略单词表和称呼列表之间的区分。每个忽略单词都以小写字母表示,并独占一行,且不会超过10个字符长度。每个称呼也独占一行,且由大写或小写字母混合表示。称呼中的单词用空格隔开,所有称呼都不会超过15个单词。
最多有50个忽略单词和200个称呼,整个输入数据(包括忽略单词表和称呼列表)不会超过10,000个字符长度。不会出现除'a'-'z'和'A'-'Z'以及空格之外的任何字母。
## 输出
要输出的是称呼的KWIC索引,对于每个称呼关键字,含有该关键字的称呼都要出现且仅出现一次,关键字按字母表顺序排列。如果一个单词在称呼中出现多于一次,那么每一次都将成为一个可能的关键字。
关键字要用大写字母输出,所有其它的字母都用小写字母。若KWIC索引中的多个称呼具有相同的关键字,则应按其在输入数据中出现的顺序输出。如果一个称呼中出现了多个相同的关键字,那么应按照大写关键字从左至右的顺序输出每一个称呼。
在确定单词是否要被忽略时不考虑大小写。
KWIC索引中的称呼无需按索引对齐,所有称呼都居左对齐即可。
## 示例输入
is
the
of
and
as
a
but
::
Descent of Man
The Ascent of Man
The Old Man and The Sea
A Portrait of The Artist As a Young Man
A Man is a Man but Bubblesort IS A DOG
Sample Output
示例输出
a portrait of the ARTIST as a young man
the ASCENT of man
a man is a man but BUBBLESORT is a dog
DESCENT of man
a man is a man but bubblesort is a DOG
descent of MAN
the ascent of MAN
the old MAN and the sea
a portrait of the artist as a young MAN
a MAN is a man but bubblesort is a dog
a man is a MAN but bubblesort is a dog
the OLD man and the sea
a PORTRAIT of the artist as a young man
the old man and the SEA
a portrait of the artist as a YOUNG man
感谢@Zhou_Liya 提供的翻译
题目描述
[problemUrl]: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=3&page=show_problem&problem=59
[PDF](https://uva.onlinejudge.org/external/1/p123.pdf)
![](https://cdn.luogu.com.cn/upload/vjudge_pic/UVA123/bc9c3fd6b71fbadb7493cdf2e142d1dbee3acca9.png)
输入输出格式
输入格式
![](https://cdn.luogu.com.cn/upload/vjudge_pic/UVA123/fd5fdaea2bef9db111538efc0102b4b62ce9a746.png)
输出格式
![](https://cdn.luogu.com.cn/upload/vjudge_pic/UVA123/83ef5b49378d2635aa5c2170348c79127dff0708.png)
输入输出样例
输入样例 #1
is
the
of
and
as
a
but
::
Descent of Man
The Ascent of Man
The Old Man and The Sea
A Portrait of The Artist As a Young Man
A Man is a Man but Bubblesort IS A DOG
输出样例 #1
a portrait of the ARTIST as a young man
the ASCENT of man
a man is a man but BUBBLESORT is a dog
DESCENT of man
a man is a man but bubblesort is a DOG
descent of MAN
the ascent of MAN
the old MAN and the sea
a portrait of the artist as a young MAN
a MAN is a man but bubblesort is a dog
a man is a MAN but bubblesort is a dog
the OLD man and the sea
a PORTRAIT of the artist as a young man
the old man and the SEA
a portrait of the artist as a YOUNG man