/**
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","tuv","wxyz"};
[字典树] hdu 1298 poj 1451 T9
最新推荐文章于 2021-06-30 13:05:47 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)