博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
字典树[HDU-1251]
阅读量:2352 次
发布时间:2019-05-10

本文共 691 字,大约阅读时间需要 2 分钟。

模板题

#include
#include
#include
#include
#include
#include
using namespace std;struct node{ int cnt; struct node *next[26]; node() { cnt = 0; memset(next,0,sizeof(next)); }};node *root = NULL;void buildtrie(char *s){ node *p = root; node *tmp = NULL; int len = strlen(s); for(int i = 0; i <= len - 1; i++) { if(p->next[s[i] - 'a'] == NULL) { tmp = new node; p->next[s[i] - 'a'] = tmp; } p = p->next[s[i] - 'a']; p->cnt ++; }}void findtrie(char *s){ node *p = root; int len = strlen(s); for(int i = 0; i <= len - 1; i++) { if(p->next[s[i] - 'a'] == NULL) { cout << 0 << endl; return ; } p = p -> next[s[i]-'a']; } cout << p->cnt <

 

转载地址:http://fnwtb.baihongyu.com/

你可能感兴趣的文章
CSS3渐变
查看>>
CSS实现居中的7种方法
查看>>
Charles拦截不到请求
查看>>
gitlab/github 多账户下设置 ssh keys
查看>>
Mac版 charles安装与破解
查看>>
keydown、keypress、keyup的使用
查看>>
区块链是否做好了迎接法币的准备?为什么银行如此看好加密货币?
查看>>
加密货币--Cryptocurrency
查看>>
Myeclipse的不足之一,struts 配置 action
查看>>
input /button链接方法
查看>>
CSS,font-family,好看,常用,中文,字体(更新中)
查看>>
Redis---基础知识:数据类型、持久化机制、虚拟内存、高级特性、应用场景
查看>>
Python3---获取延迟、提前的时间、日期---datetime、time
查看>>
Python3+selenium+Chrome---获取表格(tbody)中数据(tr)的详细内容----a & td内容的获取
查看>>
Docker/Podman使用提高----Dockerfile的制作基础及常见的问题
查看>>
Jenkins持续部署---centos7+Docker+Github+Flask项目-------补丁篇
查看>>
C语言基础---指针数组----初始化方式&常量指针数组、指针常量数组
查看>>
C语言基础---数组、指针之间的相同与不同
查看>>
类的继承的应用场景
查看>>
python3 + selenium------Chrome和Firefox 驱动的使用和版本对应
查看>>