随笔分类 -  字符串--trie树

摘要:http://poj.org/problem?id=3007静态的trie树 静cz提醒 把初始化改了改 不TLE了 分8种情况讨论 有一种就是与源串相同放在最后处理就行View Code 1 #include <iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<stdlib.h> 5 #include<algorithm> 6 using namespace std; 7 struct node 8 { 9 int cout; 10 int next[27]; 1 阅读全文
posted @ 2013-02-20 16:32 _雨 阅读(205) 评论(0) 推荐(0)
摘要:http://poj.org/problem?id=2418 trie树,有非空格、字母的字符View Code 1 #include <iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<stdlib.h> 5 #include<algorithm> 6 using namespace std; 7 typedef struct node 8 { 9 int num;10 struct node *next[130];11 node()12 {13 memset(n 阅读全文
posted @ 2013-01-20 15:45 _雨 阅读(184) 评论(0) 推荐(0)
摘要:http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=1500View Code 1 #include <iostream> 2 #include<cstdio> 3 #include<string.h> 4 #include<stdlib.h> 5 using namespace std; 6 struct node 7 { 8 int flag; 9 node *next[27];10 node()11 {12 flag = 0;13 m... 阅读全文
posted @ 2012-08-13 14:42 _雨 阅读(175) 评论(0) 推荐(0)
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1075难得的1A 把对应的英语单词存在 火星文字最后一个字母的结构体字符串中 挨个找View Code 1 #include <iostream> 2 #include<cstdio> 3 #include<string.h> 4 #include<stdlib.h> 5 using namespace std; 6 int flag; 7 struct node 8 { 9 int flag; 10 char s[21]; 11 node *next[27]; 阅读全文
posted @ 2012-08-13 11:27 _雨 阅读(217) 评论(0) 推荐(0)
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1247先找某个单词是否为一个单词的前缀 再用 这个单词减去前缀 判断剩下的部分是否为一个单词View Code 1 #include <iostream> 2 #include<stdlib.h> 3 #include<cstdio> 4 #include<string.h> 5 using namespace std; 6 char c[50001][101]; 7 struct node 8 { 9 int flag;10 node *next[27];11 阅读全文
posted @ 2012-08-13 10:26 _雨 阅读(192) 评论(0) 推荐(0)
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1251将每次走过得字母统计数量 查找的时候输出字母数量的最小值View Code 1 #include<stdio.h> 2 #include<iostream.h> 3 #include<string.h> 4 struct node 5 { 6 int count; 7 node *next[27]; 8 node() 9 {10 count = 0;11 memset(next,NULL,sizeof(next));12 }13 ... 阅读全文
posted @ 2012-07-24 20:59 _雨 阅读(202) 评论(0) 推荐(0)
摘要:http://dongxicheng.org/structure/trietree/http://hi.baidu.com/piaoshi111/item/ad5f7c12ca63f38889a95622http://poj.org/problem?id=3630刚开始套字典树 将字符串末尾标记 查询到末尾时标记 动态的 超时了 参考着别人的写了个静态的 过了 172MSView Code 1 #include 2 #include 3 #include 4 using namespace std; 5 struct node 6 { 7 int count; 8 int n... 阅读全文
posted @ 2012-07-22 11:25 _雨 阅读(259) 评论(0) 推荐(0)