/**
字典树
判断是否存在一个字符串为另一个的前缀。
字典树果然还是不能动态开辟空间呢,TLE的伤不起鸟。
*/
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
#define N 100000
struct tireTree
{
bool isNum;
tireTree *tr[10];
}tt[N];
struct Phone
{
char str[11];
int len;
}s[N];
bool cmp(Phone a,Phone b)
{
return a.len < b.len;
}
tireTree *ps;
bool insert(string s,tireTree *&rt)
{
int num;
if(rt == NULL)
rt = ps++;
tireTree *loc = rt;
for(int i = 0; s[i]; ++i)
{
num = s[i] - '0';
if(loc->tr[num] == NULL)
loc -> tr[num] = ps++;
loc = loc-
[字典树 ] poj 3630 Phone list
最新推荐文章于 2020-11-10 18:49:30 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)