Phone List HDU1671
字典树的包含与不包含关系
#include<bits/stdc++.h>
using namespace std;
int trie[][];
int sum[];
int pos=; bool insert1( char *word )
{
int root=;
for(int i=;i<strlen(word);i++)
{ int ch=word[i]-'';
if(trie[root][ ch ]==)
trie[root][ ch ]=++pos;
if(sum[root]==&&root!=)return false;
sum[root]=;
root=trie[root][ch]; }
if(sum[root]!=) sum[root]=;
else return false;
return true;
} int main()
{
int cas;scanf("%d",&cas);
while(cas--)
{
pos=;
int n;
memset(sum,false,sizeof(sum));
memset(trie,,sizeof(trie));
char word[];
scanf("%d",&n);
int ok=;
while(n--)
{
scanf("%s",word);
if(ok==)continue;
if(!insert1(word)){ok=;} }
if(ok)printf("YES\n");
else printf("NO\n"); } }
Phone List HDU1671的更多相关文章
- Trie的C++实现及HDU1251,hdu1671
#include<iostream> #include<cstdio> #include<string> #include<cstring> #incl ...
- 3道入门字典树例题,以及模板【HDU1251/HDU1305/HDU1671】
HDU1251:http://acm.hdu.edu.cn/showproblem.php?pid=1251 题目大意:求得以该字符串为前缀的数目,注意输入格式就行了. #include<std ...
- HDU1671——前缀树的一点感触
题目http://acm.hdu.edu.cn/showproblem.php?pid=1671 题目本身不难,一棵前缀树OK,但是前两次提交都没有成功. 第一次Memory Limit Exceed ...
- HDU1671 字典树
Phone List Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total ...
- hdu----(1671)Phone List(Trie带标签)
Phone List Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total ...
- HDU1671 - Phone List(Trie树)
题目大意 给定一些电话号码,判断是否有电话号码是其他电话号码的前缀 题解 裸Trie树嘛~~~~只需要一个插入过程即可,假设X是Y的前缀,在插入的过程中有两种情况,X在Y之前插入,那么在插入Y的时候经 ...
- hdu1671字典树
Phone List Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total ...
- HDU1671 Phone List
Phone List Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Probl ...
- HDU1671 水题字典树
#include<cstdio> #include<cstdlib> #include<iostream> #include<cstring> #inc ...
随机推荐
- 12. SpringBoot国际化
1).编写国际化配置文件: 2).使用ResourceBundleMessageSource管理国际化资源文件 3).在页面使用fmt:message取出国际化内容 步骤:1).编写国际化配置文件,抽 ...
- collocation
a collocation is two or more words that often go together. These combination just sound "right& ...
- Java SE之向上转型(动态绑定)与向下转型
[Keywords]:向上转型 向下转型 动态绑定[1] 静态绑定[Abstract]:Java调用对象方法时,一般采用运行时绑定机制.[1] 在程序运行时,采用动态绑定意味着:虚拟机 ...
- php ldap
参考链接: http://blog.csdn.net/guoyuqi0554/article/details/11015403 http://blog.csdn.net/qk1992919/artic ...
- [转]bus error与segment error
在c程序中,经常会遇到段错误(segment error)和总线错误(bus error),这两种问题出现的原因可能如下 段错误: 对一个NULL指针解引用. 访问程序进程以外的内存空间. 实际上,第 ...
- SpringMVC 使用@ResponseBody返回json 中文乱码与返回实体类报错
有时候我们发现接收的是中文,返回却是个?.这确实是个蛋疼的问题,Spring中解析字符串的转换器默认编码居然是ISO-8859-1 /** * Implementation of {@link Htt ...
- Android常用逆向工具+单机游戏破解
android开发环境搭建 我理解的学习路线是首先要掌握和了解常见的工具.搭建环境.然后就是缓慢的积累特征,通过长期的练习使自己进步,通过android逆向课程的学习.常用的工具如下: android ...
- centos6安装python3.6.4
安装Python依赖包: [root@Python src]# yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlit ...
- linux 查看cpu的使用百分比
先安装 sudo apt-get install sysstat 然后: mpstat -u 2 5
- python的技巧和方法你了解多少?
学了这些你的python代码将会改善与你的技巧将会提高. 1. 路径操作 比起os模块的path方法,python3标准库的pathlib模块的Path处理起路径更加的容易. 获取当前文件路径 前提导 ...