博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
HDOJ1251解题报告【字典树】
阅读量:4363 次
发布时间:2019-06-07

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

题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=1251

题目概述:

  给你一些单词和一些询问,对于每个询问求出所有单词中以询问为前缀的单词个数。

大致思路:

  稍微修改一下Tire树就好了,对每个节点增加一个标记来记录到这个节点共有几个单词,这个题还需要注意用g++提交指针版的会MLE,所以需要用数组形式的Tire树。

  年轻的我还是被输入给坑了……果然naive.

代码:

1 #include 
2 #include
3 #include
4 #include
5 #include
6 #include
7 #include
8 #include
9 #include
10 #include
11 using namespace std;12 13 #define sacnf scanf14 #define maxn 100001015 #define inf 106110956716 #define Eps 0.00117 #define PI 3.141592718 #define mod 997319 #define MAXNUM 1000020 void Swap(int &a,int &b) { int t=a;a=b;b=t;}21 int Abs(int x) { return (x<0)?-x:x;}22 typedef long long ll;23 24 int tree[maxn][26];25 int cnt[maxn];26 int dir=1;27 28 void Insert(char *s)29 {30 int p=0,len=strlen(s);31 for(int i=0;i

 

转载于:https://www.cnblogs.com/CtrlKismet/p/6337965.html

你可能感兴趣的文章
SQLSERVER如何获取一个数据库中的所有表的名称、一个表中所有字段的名称
查看>>
Linux 常用命令二 pwd cd
查看>>
Axis通过wsdd部署Web Service
查看>>
【SQL】sql版Split函数。用于拆分字符串为单列表格
查看>>
HashMap实现原理分析
查看>>
第一冲刺阶段工作总结02
查看>>
Python操作Redis(转)
查看>>
Xshell 基本使用方式 (1) -- 使用Xshell 连接 VMware下的linux系统
查看>>
[BZOJ1726][Usaco2006 Nov]Roadblocks第二短路
查看>>
Bundle Identifier
查看>>
node--更新数据库问题
查看>>
《JavaScript权威指南》学习笔记 第二天 下好一盘大棋
查看>>
PHP 进程详解
查看>>
51nod 1278 相离的圆
查看>>
程序媛,坚持这几个好习惯让你越来越美
查看>>
如何在本地运行查看github上的开源项目
查看>>
类成员函数模板特化
查看>>
十个利用矩阵乘法解决的经典题目
查看>>
sublime text3
查看>>
WPF 反编译后错误处理
查看>>