the expound of tire or the interpret of tire or the explicate of tire or the explain of tire(no face)

include

include

const int M = 50000;
struct tire{//路径上的权值代表字母
int nex[M][26],cnt;
bool is[M];
void insert(char *s,int l){
int p=0;//踹树节点从0开始 ,from
for(int i=0;i<l;++i){
int c = s[i]-'A';//当前的字母
if(!nex[p][c])nex[p][c]=++cnt;//p到c无权值,建新点
p = nex[p][c];//让p =to
}
is[p] = 1;//表示到现在的点 存在字母
}
bool find(char *s,int l){
int p=0;
for(int i=0;i<l;i++){
int c=s[i]-'a';
if(!nex[p][c])return 0;//只要没有就0
p = nex[p][c];//p = to
}
return is[p];//最后验证是否有
}
};
tire T;
int main(){
char s[M];
while(scanf("%s",s)!=EOF){
T.insert(s,strlen(s));
}
printf("%d",T.cnt+1);
return 0;
}

posted @ 2022-02-15 12:00  zasdcn  阅读(35)  评论(0编辑  收藏  举报