HUD 2846 Repository】的更多相关文章

/* 开始想耍小聪明 直接map搞 代码短 好理解 空间够 恩 很好 就是 map慢死了 T了 */ #include<iostream> #include<cstdio> #include<cstring> #include<map> using namespace std; int n,m,ans; string s,si; map<string,int>t; int main() { cin>>n; while(n--) { m…
http://acm.hdu.edu.cn/showproblem.php?pid=2846 Repository Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 2720    Accepted Submission(s): 1060 Problem Description When you go shopping, you can s…
Repository Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 2932    Accepted Submission(s): 1116 Problem Description When you go shopping, you can search in repository for avalible merchandises…
Repository Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 6444    Accepted Submission(s): 2096 Problem Description When you go shopping, you can search in repository for avalible merchandises b…
题目大意:给你n个字符串,然后给你m个子串,看这个子串在上面的多少个串中,出现过: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2846 本题可以在字典树上进行改进: AC代码: #include<iostream> #include<cstdio> #include<cstring> #include<cstdlib> using namespace std; ; typedef struct node {…
RepositoryTime Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 7233    Accepted Submission(s): 2278 Problem DescriptionWhen you go shopping, you can search in repository for avalible merchandises by…
题目 字典树,注意初始化的位置~!!位置放错,永远也到不了终点了org.... 我是用数组模拟的字典树,这就要注意内存开多少了,,要开的不大不小刚刚好真的不容易啊.... 我用了val来标记是否是同一个串分解而来的,保存的是串的编号 num记录数目. //string &replace(iterator first0, iterator last0,const_iterator first, const_iterator last); //把[first0,last0)之间的部分替换成[firs…
字典树较为复杂的应用,我们在建立字典树的过程中需要把所有的前缀都加进去,还需要加一个id,判断它原先是属于哪个串的.有人说是AC自动机的简化,但是AC自动机我还没有做过. #include<iostream> #include<string.h> #include<cstdio> using namespace std; ],b[]; struct Node { int id,num; Node *sons[]; Node() { id = -,num = ; ; j…
传送门:http://acm.hdu.edu.cn/showproblem.php?pid=2846 Repository Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Problem Description When you go shopping, you can search in repository for avalible merchandises by the com…
http://acm.hdu.edu.cn/showproblem.php?pid=2846 题意:给出N个模式串,再给出M个文本串,问每一个文本串在多少个模式串中出现. 思路:平时都是找前缀的,这里将模式串s[1……len]的每一个[i,len]的子串都插入,这样就可以满足条件.还要注意如果两个子串都为同一个模式串的子串,不能重复计数.可以用一个id数组装上一次是哪个串的id,如果id相同就不要重复计数了. #include <cstdio> #include <algorithm&g…