随笔分类 -  字典树

poj 2002 Babelfish
摘要:算法:1.map 985ms..2.Trie树,250ms..4倍。。3.排序+二分查找 200ms左右struct dict{ char a[11]; char b[11];}dic[100001];4. HASH将字符串映射为一个HASH值,HASH函数可以从网上自己找一个用静态链表处理冲突,速度最快235msView Code /*代码自己没写了,此代码来自http://wingszero.blogbus.com/logs/60733344.html*/#include<iostream>#include<string>using namespace std;co 阅读全文

posted @ 2012-07-21 16:28 more think, more gains 阅读(153) 评论(0) 推荐(0)

phone list
摘要:#include <stdio.h>#include <string.h>#include <stdlib.h>#include <cstdlib>#include <istream>#define MAX 10struct Trie { Trie *next[MAX]; int v;};Trie *root;void creattrie(char *str){ int i, j, len, t; Trie *p, *q; p = root; len = strlen(str); for (i = 0; i < len; i++ 阅读全文

posted @ 2011-07-20 11:34 more think, more gains 阅读(129) 评论(0) 推荐(0)

字典树 统计难题
摘要:#include <stdio.h>#include <string.h>#include <stdlib.h>#define MAX 26struct Trie { Trie *next[MAX]; int v;};Trie *root;void creattrie(char *str){ Trie *p, *q; int t, len, i, j; p = root; len = strlen(str); for (i = 0; i < len; i++) { t = str[i] - 'a'; if(p->next[t] = 阅读全文

posted @ 2011-07-20 11:33 more think, more gains 阅读(160) 评论(0) 推荐(0)

导航