trie
Benzema67
北京邮电大学学生
展开
-
poj 3630
这道题是得用静态内存方式的trie树,动态链表形式的trie树会TLE#include#include#includeconst int Max=10;using namespace std;struct trie{ int next[Max]; int flag;}node[100000];int num;struct trie root;bool inse原创 2012-06-26 22:08:36 · 939 阅读 · 0 评论 -
poj 2001
标准trie字典树全局指针变量默认赋值NULL#include#include#includeconst int MAX=26;char str[1000][21],res[1000][21];struct node{ struct node *next[MAX]; //字母分支 int flag; //字母出线过的次数统计}node;struct node *原创 2012-06-26 01:39:56 · 1087 阅读 · 0 评论 -
poj 1451
dfs+字典树(方法很暴力。。)#include#include#includeconst int Max=26;using namespace std;struct trie{ struct trie * next[Max]; int flag; trie(){ flag=0; for( int i = 0; i < 26原创 2012-06-26 16:12:08 · 1189 阅读 · 0 评论 -
POJ 1204
这个题查询的两个串有可能有公共前缀trie树做法#include#include#include#includeconst int kind=26;using namespace std;char s[1010][1010];int h[]={-1,-1,0,1,1,1,0,-1};int g[]={0,1,1,1,0,-1,-1,-1};int m,n,q,原创 2012-07-16 16:11:58 · 1149 阅读 · 0 评论 -
POJ 3764
trie树#include#include#define N 100100#define M 2using namespace std;int n;struct Edge{ int v,w,next;}edge[N*2];int head[N],cnt,cou;int dis[N];void addedge(int u,int v,int w){ edge[原创 2012-08-28 15:53:07 · 1325 阅读 · 0 评论 -
UVALive 3942 Remember the Word
利用Trie树进行转移#include#include#define MAXN 400003#define SN 26#define MAXL 300003#define MOD 20071027using namespace std;struct Trie { Trie *s[SN]; bool end; void clear() {原创 2012-08-28 01:33:48 · 1100 阅读 · 0 评论 -
HDU 4757
可持久化trie树。不会可持久化数据结构的话推荐先看陈立杰的论文。先掌握可持久化线段树和可持久化trie树。原创 2013-10-13 19:02:10 · 2292 阅读 · 0 评论