hihocoder 1014: Trie树(Trie树模板题)
2024-10-07 13:17:33
#include<bits/stdc++.h> using namespace std; ; struct T { int num; T* next[]; T() { num=; int i; ;i<;i++) next[i]=NULL; } }t; void insert(char str[]) { T* p=&t; ;str[i];i++) { int a=str[i]-'a'; if(p->next[a]==NULL) p->next[a]=new T; p=p->next[a]; p->num++; } } int find(char str[]) { T* p=&t; ;str[i];i++) { int a=str[i]-'a'; if(p->next[a]==NULL) ; p=p->next[a]; } return p->num; } int main() { int n,m; char str[L]; scanf("%d",&n); while(n--) scanf("%s",str),insert(str); scanf("%d",&m); while(m--) scanf("%s",str),printf("%d\n",find(str)); }
最新文章
- sh7.创建yum源脚本练习
- (转)Ubuntu samba配置服务文件包
- 结合仓库设计MVC控制器
- jquery 设置元素内容html(),text(),val()
- HDU 4884 TIANKENG’s rice shop (模拟)
- HTTPConnection与HTTPClient的区别
- Articulate Studio课间制作工具
- shell环境
- ural 1348 Goat in the Garden 2
- c++继承构造子类调用父类构造函数的问题及关于容器指针的问题及当容器里储存指针时,记得要手动释放
- RMAN多种备份脚本分享
- CentOS 7 yum搭建 LAMP
- 201521123001《Java程序设计》第5周学习总结
- 笨办法33while循环
- hdfs数据采集场景示意图
- 如何恢复Eclipse中被误删除的文件
- 【解决】Can&#39;t find default configuration ";arch/x86/configs/xx_defconfig";!
- Hyper-V 连网备忘
- android -------- ConstraintLayout介绍 (一)
- SpringBoot进阶之web进阶
热门文章
- 原来在UNITY中使用system.io下的所有函数都可以用相对路径 : Assets/xx
- Tomcat GC参数详解
- scrapy基础笔记
- python简单的函数定义和用法实例
- Repository模式--采用EF Fluent API使用EntityTypeConfiguration分文件配置Model映射关系
- 软件体系结构-分层、代理、MVC、管道与过滤器
- Mac009--Axure RP安装
- 基于dvwa环境下级别为low的SQL手工注入教程
- Js数据去重复,时间更换格式,cookie,localStorage和sessionStorage的使用等通用方法
- http响应代码解释