问题 : Engine-字符串
来源:互联网 发布:九阴真经捏脸数据 编辑:程序博客网 时间:2024/06/03 20:18
题目描述
谷歌、百度等搜索引擎已经成为了互连网中不可或缺的一部分。在本题中,你的任务也是设计一个搜索论文的搜索引擎,当然,本题的要求比起实际的需求要少了许多。
本题的输入将首先给出一系列的论文,对于每篇论文首先给出标题,然后给出它被引用的次数。然后会有一系列的搜索询问,询问标题中包含特定关键词的论文有哪些。
每一个询问可能包含多个关键词,你需要找出标题包含所有关键词的论文。
“包含”必须是标题中有一个词正好是给定的关键词,不区分大小写。
对每个询问,都按被引用的次数从多到少输出满足条件的论文的标题。如果有被引用的次数相同的论文,则按照论文在输入中的顺序排列,先给出的论文排在前面。
输入
输入包含多组数据。
每组数据首先有一行包含一个整数N(1<=N<=1000),表示论文的数目,N=0表示输入结束。每组论文的信息第一行是论文的标题,由字母(大小写均可)和空格组成,不超过10个词,每个词不超过20个字符,标题总共不超过250个字符。第二行是一个整数K(0<=K<=108),表示它被引用的次数。在论文信息结束以后,有一行包含一个整数M(1<=M<=100),表示询问的数目。接下来有M行,每行是一个询问,由L(1<=L<=10)个空格分开的词构成,每个词不超过20个字符。
输出
对每个询问,按照题目给定的顺序输出满足条件的论文的标题;如果没有满足条件的论文,就不输出。在每组询问的输出之后输出一行“*”,在每组数据的输出之后输出一行“—”。
样例输入
6
Finding the Shortest Path
120
Finding the k Shortest Path
80
Find Augmenting Path in General Graph
80
Matching in Bipartite Graph
200
Finding kth Shortest Path
50
Graph Theory and its Applications
40
6
shortest path
k shortest path
graph
path
find
application
0
样例输出
Finding the Shortest Path
Finding the k Shortest Path
Finding kth Shortest Path
Finding the k Shortest Path
Matching in Bipartite Graph
Find Augmenting Path in General Graph
Graph Theory and its Applications
Finding the Shortest Path
Finding the k Shortest Path
Find Augmenting Path in General Graph
Finding kth Shortest Path
Find Augmenting Path in General Graph
*
AC代码
#include <iostream>#include<algorithm>using namespace std;struct s{ string heading; int _count;};struct s node[1000];bool compare(s a,s b){ if(a._count>b._count) return true; else return false;}int main(){ int n,p; while(cin>>n&&n!=0){ p=0; while(n--){ cin.get(); getline(cin,node[p].heading); cin>>node[p]._count; p++; } int m; cin>>m; cin.get(); while(m--){ string findstr;int sum=0; struct s result[1000]; getline(cin,findstr); int len=findstr.size(); for(int i=0;i<p;i++){ int lenb=node[i].heading.size(); int flag; for(int x=0;x<lenb;x++){ flag=1; for(int j=0;j<len;j++){ if(findstr[j]!=node[i].heading[x+j]&&findstr[j]!=node[i].heading[x+j]-32&&findstr[j]!=node[i].heading[x+j]+32){ flag=0; break; } if(isalpha(node[i].heading[x+len])){ flag=0; break; } } if(flag){ result[sum].heading=node[i].heading; result[sum]._count=node[i]._count; sum++; break; } } } sort(result,result+sum,compare); for(int k=0;k<sum;k++){ cout<<result[k].heading<<endl; } cout<<"***"<<endl; } cout<<"---"<<endl; } return 0;}
- 问题 : Engine-字符串
- Engine-字符串
- HDU2532 Engine 字符串+模拟
- arc engine 问题
- Unreal Engine 4 字符串转换
- Unreal Engine 4 字符串转换
- ovirt-engine搭建问题总结
- 杭电acm 2532Engine(字符串)
- engine
- Engine
- Engine
- 提交Mozilla JavaScript Engine的一个问题
- 关于Arcgis engine for eclipse 安装问题
- Arcgis Engine WIN7 64位系统兼容性问题
- DM6446 Codec Engine问题总结及解决办法
- DM6446 Codec Engine问题总结及解决办法
- Genymotion问题二 Initialize Engine: failed
- google app engine java 包问题
- maven环境配置
- 快速傅里叶转换 模版
- 在Linux中怎样修改hostname(主机名)
- 【支付系统学习笔记】-支付系统整体架构
- 机房收费系统-上下机
- 问题 : Engine-字符串
- LA3983 Robotruck
- 号称精通Java的你,是否真的名副其实
- HTTP2 新特性
- 将博客搬至CSDN》的文章, 并将文章地址填写在上方的"搬家通知博文地址"中。
- HTML <form> 标签的 enctype 属性
- Mycat之——错误处理总结
- Redis--keyspace notification(键空间)
- HDU6108 小C的倍数问题(进制+唯一分解定理)