又是一个比较困难一些的搜索的问题,运用C语言程序设计的思路

Problem Description
For this problem you will write a search engine that takes a query, searches a collection of words, and finds the lexicographically smallest word that matches the query (i.e., the matching word that would appear first in an English dictionary). A query is a sequence of one or more terms separated by single vertical bars ("|"). A term is one or more letters followed by zero or more signed letters. A signed letter is either +s ("positive" s) or -s ("negative" s), where s is a single letter. All letters are lowercase, and no letter will appear more than once within a term. A query will not contain spaces. A term matches a word if the word contains at least one of the unsigned letters, all of the positive letters, and none of the negative letters; a query matches a word if at least one of its terms matches the word.

Input
The input consists of one or more test cases followed by a line containing only "#" that signals the end of the input. Each test case consists of 1–100 words, each on a line by itself, followed by a line containing only "*" that marks the end of the word list, followed by one or more queries, each on a line by itself, followed by a line containing only "**" that marks the end of the test case. Each word will consist of 1–20 lowercase letters. All words within a test case will be unique. Each query will be as defined above and will be 1–79 characters long.

Output
For each query, output a single line containing the lexicographically smallest word within that test case that matches the query, or the word NONE if there is no matching word. At the end of each test case, output a dollar sign on a line by itself.

Sample Input
elk
cow
bat
*
ea
acm+e
nm+o|jk+l
**
debian
slackware
gentoo
ubuntu
suse
fedora
mepis
*
yts
cab-e+n
r-e|zjq|i+t|vs-p+e-u-c
**
#

Sample Output
bat
NONE
elk
$
gentoo
ubuntu
NONE
$

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问

相似问题

2
C语言程序中return用法
1
运用C语言的编程功能实现猜数字的程序
1
一个有关汉诺塔方面的C语言编程题,比较困难一些
1
新人求助,关于c语言程序运行结果的问题
3
关于嵌入式操作系统的一个题目,编写一个c语言程序,其功能是将一个文本文件读出,然后再反序写回。
0
数组在图上的移动的一个算法的问题,要综合运用C语言知识的程序的编写
3
运用C语言的编程的技术,编写一个程序,判断给定的两个数是否是亲和数
0
如何运用C语言程序编写的技术来实现这个方块移动的问题的
0
一个比较复杂很绕的动态组合的问题,运用C语言实现的解决的办法是什么
0
一个二分图的遍历搜索方面的问题,如何运用C语言的技术解答这个问题的
0
一个多项是的公式的计算问题,运用C语言编程技术的实现的方式是
0
广度优先遍历的路径搜索算法问题怎么解决?运用C语言的程序编写方式
0
一笔画连通的有效性的判断的问题,运用C语言的程序办法实现
0
高阶图形的算法问题,图像的匹配数运用C语言程序算法实现怎么实现
0
求Fibbonacci级数的中间指定的项的值问题,运用C语言的程序编写的方式怎么做
0
切蛋糕的一个算法问题,计算每块边长,运用C语言程序的编写的技术
0
计算在翻纸牌游戏中翻转次数最少的方案,运用C语言的程序的编写的办法
0
推箱子的问题用最少的步数实现,C语言程序的运用问题怎么来实现的
0
最短路经解决这里的算法问题,如何穷举,运用C语言的程序设计方法
0
最大的二进制子序列的查找算法,运用C语言的程序的设计的原理实现