/**
字典树
判断是否存在一个字符串为另一个的前缀。
字典树果然还是不能动态开辟空间呢,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->tr[num];
if(loc -> isNum)
return 0;
}
loc-&g