首页 > ACM题库 > HDU-杭电 > HDU 2846-Repository[解题报告]HOJ
2014
02-17

HDU 2846-Repository[解题报告]HOJ

Repository

问题描述 :

When you go shopping, you can search in repository for avalible merchandises by the computers and internet. First you give the search system a name about something, then the system responds with the results. Now you are given a lot merchandise names in repository and some queries, and required to simulate the process.

输入:

There is only one case. First there is an integer P (1<=P<=10000)representing the number of the merchanidse names in the repository. The next P lines each contain a string (it’s length isn’t beyond 20,and all the letters are lowercase).Then there is an integer Q(1<=Q<=100000) representing the number of the queries. The next Q lines each contains a string(the same limitation as foregoing descriptions) as the searching condition.

输出:

There is only one case. First there is an integer P (1<=P<=10000)representing the number of the merchanidse names in the repository. The next P lines each contain a string (it’s length isn’t beyond 20,and all the letters are lowercase).Then there is an integer Q(1<=Q<=100000) representing the number of the queries. The next Q lines each contains a string(the same limitation as foregoing descriptions) as the searching condition.

样例输入:

20
ad
ae
af
ag
ah
ai
aj
ak
al
ads
add
ade
adf
adg
adh
adi
adj
adk
adl
aes
5
b
a
d
ad
s

样例输出:

0
20
11
11
2

#include <list> 
#include <map> 
#include <set> 
#include <queue> 
#include <string> 
#include <deque> 
#include <stack> 
#include <algorithm> 
#include <iostream> 
#include <iomanip> 
#include <cstdio> 
#include <cmath> 
#include <cstdlib> 
#include <limits.h> 
#include <time.h> 
#include <string.h> 
using namespace std; 
 
#define LL long long 
#define PI acos(-1.0) 
#define Max INT_MAX 
#define Min INT_MIN 
#define eps 1e-8 
#define FRE freopen("a.txt","r",stdin) 
 
struct Node{ 
 Node *next[26]; 
 int inid; 
 int pass; 
 Node(){ 
 pass=0; 
 inid=0; 
 for(int i=0;i<26;i++) 
 next[i]=NULL; 
 } 
}; 
void add(char *str,int beg,int si,Node *root){ 
 int i,j; 
 Node *pos=root; 
 for(i=beg;str[i];i++){ 
 int id=str[i]-'a'; 
 if(pos->next[id]==NULL) 
 pos->next[id]=new Node(); 
 
 pos=pos->next[id]; 
 if(pos->inid==si)continue; 
 pos->inid=si; 
 pos->pass++; 
 } 
} 
void substr(char *str,int si,Node *&root){ 
 int i,j; 
 for(i=0;str[i];i++){ 
 add(str,i,si,root); 
 } 
} 
void find(Node *root,char *str){ 
 int i,j; 
 Node *pos=root; 
 for(i=0;str[i];i++){ 
 int id=str[i]-'a'; 
 if(pos->next[id]==NULL){ 
 printf("0\n"); 
 return ; 
 } 
 pos=pos->next[id]; 
 } 
 printf("%d\n",pos->pass); 
} 
void release(Node *root) 
{ 
 int i; 
 for (i = 0; i < 26; ++i) 
 { 
 if (root->next[i] != NULL) 
 { 
 release(root->next[i]); 
 } 
 } 
 delete (root); 
} 

int main(){ 
 int n; 
 char str[22]; 
 while(scanf("%d",&n)!=EOF){ 
 int i,j; 
 Node *root = new Node(); 
 for(i=1;i<=n;i++){ 
 scanf("%s",str); 
 substr(str,i,root); 
 } 
 int m; 
 scanf("%d",&m); 
 while(m-- && scanf("%s",str)){ 
 find(root,str); 
 } 
 release(root); 
 } 
 return 0; 
}

  1. Hello Web Admin, I noticed that your On-Page SEO is is missing a few factors, for one you do not use all three H tags in your post, also I notice that you are not using bold or italics properly in your SEO optimization. On-Page SEO means more now than ever since the new Google update: Panda. No longer are backlinks and simply pinging or sending out a RSS feed the key to getting Google PageRank or Alexa Rankings, You now NEED On-Page SEO. So what is good On-Page SEO?First your keyword must appear in the title.Then it must appear in the URL.You have to optimize your keyword and make sure that it has a nice keyword density of 3-5% in your article with relevant LSI (Latent Semantic Indexing). Then you should spread all H1,H2,H3 tags in your article.Your Keyword should appear in your first paragraph and in the last sentence of the page. You should have relevant usage of Bold and italics of your keyword.There should be one internal link to a page on your blog and you should have one image with an alt tag that has your keyword….wait there's even more Now what if i told you there was a simple WordPress plugin that does all the On-Page SEO, and automatically for you? That's right AUTOMATICALLY, just watch this 4minute video for more information at.