LeeBlog

导航

随笔分类 -  字典树

HDU 1671 Phone List
摘要:这题是字典树的以简单题但我开始一直不能水过,后来才发现rt用的不是自定义,再循环使用时没有初始化,后来将结构体自定义,果断水过,表示以后所有的结构体都用自定义#include<stdio.h>#include<stdlib.h>#include<string.h>const int max = 10;typedef struct T{ T *ch[max]; int f; }Trie;int flag = 1; char in[50];void init( T *t ){ t -> f = 0; for( int i = 0; i < max; 阅读全文

posted @ 2011-03-15 22:22 LeeBlog 阅读(190) 评论(0) 推荐(0)

HDU 1251 统计难题 字典树
摘要:此题用字典树做,很快,据小白说还有一种方法:把每个单词的第一个字母存进去,然后再进行字符串比较,这样刚好不超时#include<stdio.h>#include<string.h>#include<stdlib.h>struct T{ T *ch[26]; int n;}rt;char in[30];void init( T *t ){ t -> n = 0; for( int i = 0; i < 26; ++i ) t -> ch[ i ] = NULL; }void insert( T *t,char *in ){ if( t -&g 阅读全文

posted @ 2011-03-14 22:09 LeeBlog 阅读(171) 评论(0) 推荐(0)