/**
poj 1451 T9
在hdu 1298 上WA了,
原来问题出在单词的数目上,审题不慎,字符串长度开始定位10,
没注意到题目说单词数目不超过100。可是竟然不给我RE,返回结果很坑爹额。。。
*/
#include <stdio.h>
#include <string.h>
#define N 50000
struct tireTree
{
int cnt;
tireTree *child[26];
tireTree()
{
cnt = 0;
for(int i = 0; i < 26; ++i)
child[i] = NULL;
}
}tt[N],*spt;
void insert(char *s,int p,tireTree *&rt)
{
tireTree *loc;
loc = rt;
int num;
for(int i = 0; s[i]; ++i)
{
num = s[i] - 'a';
if(loc->child[num] == NULL)
loc->child[num] = new tireTree;
loc = loc->child[num];
loc->cnt += p;
}
}
char t9[10][6] = {"+","-","abc","def","ghi","jkl","mno","pqrs","t
[字典树] hdu 1298 poj 1451 T9
最新推荐文章于 2021-06-30 13:05:47 发布
这篇博客主要介绍了如何使用字典树(Trie)解决HDU 1298和POJ 1451两道编程题。文章详细解析了T9输入法在数据查询和插入操作中的应用,通过C语言实现字典树结构,优化字符串匹配效率。
订阅专栏 解锁全文
566

被折叠的 条评论
为什么被折叠?



