Phone List HDU - 1671 字典树】的更多相关文章

题意:给出一堆一组一组的数字  判断有没有哪一个是另外一个的前缀 思路:字典树 插入的同时进行判断  不过 当处理一组数字的时候 需要考虑的有两点1.是否包含了其他的序列2.是否被其他序列包含 刚开始开的1e4死活不过  1e5直接过了.. #include<bits/stdc++.h> #include<string> using namespace std; ; struct Trie{ int size; ]; int isEnd[maxn]; void init(){ me…
Phone List Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 16223    Accepted Submission(s): 5456 Problem Description Given a list of phone numbers, determine if it is consistent in the sense tha…
题目:http://acm.hdu.edu.cn/showproblem.php?pid=5687 2016百度之星资格赛C题,直接套用字典树,顺便巩固了一下自己对字典树的理解 #include<stdio.h> #include<string.h> struct node{ ]; int cnt; void init(){ cnt = ;//计数 memset(next,-,sizeof(next)); } }; ]; ;//记录节点数 void insert(char *s){…
题目:http://acm.hdu.edu.cn/showproblem.php?pid=5384 用字典树.AC自动机两种做法都可以做 #include<stdio.h> #include<string.h> #include<string> #include<iostream> using namespace std; struct node{ int cnt; node *next[]; node(){ cnt = ; ;i<;i++) next…
HDU Today Time Limit: 15000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 23388    Accepted Submission(s): 5614 Problem Description 经过锦囊相助,海东集团终于度过了危机,从此,HDU的发展就一直顺风顺水,到了2050年,集团已经相当规模了,据说进入了钱江肉丝经济开发区500强.这时候,…
地址:http://acm.hdu.edu.cn/showproblem.php?pid=2072 lily的好朋友xiaoou333最近很空,他想了一件没有什么意义的事情,就是统计一篇文章里不同单词的总数.下面你的任务是帮助xiaoou333解决这个问题. Input 有多组数据,每组一行,每组就是一篇小文章.每篇小文章都是由小写字母和空格组成,没有标点符号,遇到#时表示输入结束. Output 每组只输出一个整数,其单独成行,该整数代表一篇文章里不同单词的总数. Sample Input y…
题意: t组样例,对于每一组样例第一行输入一个n,下面在输入n个数 你需要从这n个数里面找出来三个数(设为x,y,z),找出来(x+y)^z(同样也可以(y+z)^1)的最大值 ("^"代表异或操作,即"相同为0,不同为1") 题解: 这一道题和Xor Sum HDU - 4825很相似 因为异或运算的特性,我们最后要求最大值,那我们就对这n个数的二进制形式建一颗字典树.然后就暴力枚举是哪两个数相加,然后在字典树中把这两个数删掉.然后在处理完的字典树中查找那个能使结…
这道题看了大神的模板,直接用字典树提交的会爆内存,用stl 里的map有简单有快 #include <iostream> #include <map> #include <cstring> #include <string> using namespace std; int main() { int i, len; ]; map<string, int> m; while( gets(str) ) { len = strlen(str); if…
#include <iostream> #include <cstring> #include <cstdio> #include <cstdlib> #include <algorithm> using namespace std; struct Tree { Tree *next[]; bool isVirus; int num; }; Tree *root; int all; ]; ]; int n,m; void insert(char…
题意:给出很多很多很多很多个 单词 类似搜索引擎一下 输入一个单词 判断有一个字符串包含这个单词 思路:字典树变体,把每个单词的后缀都扔字典树里面,这里要注意dd是一个单词 但是把d 和dd都放字典树 拿d匹配这一个单词会匹配两次 所以要开个数组记录一下上一个使该位置数量加一的字符串 如果该字符串不是同一个 那就可以加加了 TLE:还是数组大小的问题 字典树有毒!因为一个字符串可以拆成很多个后缀所以必须开大,开大了就过了... #include<bits/stdc++.h> using nam…