Problem G: Keywords Search
Problem G: Keywords Search
Time Limit: 1 Sec Memory Limit: 128 MB
Submit: 10 Solved: 6
[Submit][Status][Web Board] [Edit] [TestData]
Description
n the modern time, Search engine came into the life of everybody like Google, Baidu, etc.
Wiskey also wants to bring this feature to his image retrieval system.
Every image have a long description, when users type some keywords to find the image, the system will match the keywords with description of image and show the image which the most keywords be matched.
To simplify the problem, giving you a description of image, and some keywords, you should tell me how many keywords will be match.
Input
First line will contain one integer means how many cases will follow by.
Each case will contain two integers N means the number of keywords and N keywords follow. (N <= 10000)
Each keyword will only contains characters 'a'-'z', and the length will be not longer than 50.
The last line is the description, and the length will be not longer than 1000000.
Output
Print how many keywords are contained in the description.
Sample Input
1
5
she
he
say
shr
her
yasherhs
Sample Output
3
#include<iostream>
#include<stdio.h>
#include<string>
#include<string.h>
using namespace std;
char b[];//存放句子
int main()
{
int n,gjc,i,j,len,lena,k,ji,count;
string a[];
while(scanf("%d",&n)!=EOF) //总的测试的个数
{
while(n--)
{
cin>>gjc;//关键词的个数
for(i=;i<gjc;i++)
{
cin>>a[i];
}
getchar();
gets(b);
len=strlen(b);
count=;
for(i=;i<gjc;i++)
{
lena=a[i].size();
for(j=;j<len;j++)
{
ji=;
for(k=;k<lena;k++)
{
if(b[j]!=a[i][k])
{
j=j-ji;
break;
}
else
{
ji++;
j++;
}
}
if(ji==lena)
{
count++;
j=j-lena;
}
}
}
cout<<count<<endl;
}
}
return ;
}
Problem G: Keywords Search的更多相关文章
- 【HDU2222】Keywords Search AC自动机
[HDU2222]Keywords Search Problem Description In the modern time, Search engine came into the life of ...
- hdu2222 Keywords Search ac自动机
地址:http://acm.split.hdu.edu.cn/showproblem.php?pid=2222 题目: Keywords Search Time Limit: 2000/1000 MS ...
- HDU 2222 Keywords Search(AC自动机模版题)
Keywords Search Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others ...
- HDU2222 Keywords Search [AC自动机模板]
Keywords Search Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others ...
- C++之路进阶——hdu2222(Keywords Search)
/*Keywords Search Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others) ...
- HDU 2222 Keywords Search(查询关键字)
HDU 2222 Keywords Search(查询关键字) Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K ...
- hdu----(2222)Keywords Search(ac自动机)
Keywords Search Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)T ...
- hdu----(2222)Keywords Search(trie树)
Keywords Search Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)T ...
- Keywords Search
Keywords Search Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
随机推荐
- tomcat path配置
<pre name="code" class="html">demo:/root# curl http://192.168.32.42:8082/a ...
- poj2190
#include <stdio.h> #include <stdlib.h> int main() { ]; ,i; scanf("%s",arr); ;i ...
- zoj2729 Sum Up(模拟)
Sum Up Time Limit: 2 Seconds Memory Limit: 65536 KB Vivid has stored a piece of private informa ...
- Pig Latin儿童黑话(java)
●假设单词以辅音字母開始,将词首的辅音字母字符串(第一个元音字母前的全部字母)从单词的开头移动到末尾,然后加上后缀ay,这样就形成了它的pig latin. ●假设单词以元音字母開始,仅仅须要 ...
- java自己主动生成验证码
代码结构: web.xml <? xml version="1.0" encoding="UTF-8"?> <web-app version= ...
- Objective-C内存管理教程和原理剖析(四)
初学Objective-C的朋友都有一个困惑,总觉得对Objective-C的内存管理机制琢磨不透,程 序经常内存泄漏或莫名其妙的崩溃.我在这里总结了自己对Objective-C内存管理机制的研究成果 ...
- 更改DataTable列名方法
1.通过DataAdapter将查询的结果填充到DataSet的表(DataTable)中: 如:dataAdapter.Fill(dataSet),这时dataSet的表名默认为Table 如果使用 ...
- eclipse开发工具Import工程后,工程文件夹上出现黄色感叹号——解决方法
eclipse开发工具Import工程后,工程文件夹上出现黄色感叹号. 可能是Work目录无效,解决方法:删除Work目录即可,如下图所示: 删除后,如下图:
- tomcat部署java项目
tomcat部署java项目 1.启动tomcat 进入到tomcat安装目录下的bin #cd /opt/tomcat/bin #./startup.sh // 执行重启命令 2.重建一个新目录导入 ...
- Django Web开发【6】使用Ajax增强用户体验
Ajax及其优点 Ajax实际上就是指异步Javascript与XML,它包含以下技术: HTML与CSS Javascript XMLHttpRequest XML Ajax技术让客户端与服务器实现 ...