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 ...
随机推荐
- collocation
a collocation is two or more words that often go together. These combination just sound "right& ...
- rest framework错误笔记——AssertionError: Cannot apply DjangoModelPermissionsOrAnonReadOnly on a view that does not set `.queryset` or have a `.get_queryset()` method.
用到@api_view装饰器时,访问路由查看api数据时,报错: AssertionError: Cannot apply DjangoModelPermissionsOrAnonReadOnly o ...
- 第16月第9天 opengl glCltDispatchTable
1.glCltDispatchTable typedef struct _GLTEBINFO { // glCltDispatchTable must be the first field for t ...
- centOS7安装Composer
1.进入Composer国内镜像网站文档页查看安装方法: https://docs.phpcomposer.com/00-intro.html 2.在centOS系统中进入特定目录执行以下命令: cd ...
- 利用 python requests完成接口文件上传
最近在准备一个公开课,主题就是利用不同的语言和不同的工具去实现文件的上传和下载. 在利用Jmeter去实现功能的时候,以及利用loadrunner去写脚本的时候,都很顺利,没有任何问题,当我尝试用Py ...
- python中dir(),__dict__
dir()是python的一个函数, dir()函数如果接受的参数是一个类,则返回这个类所有的类变量和方法 dir()函数如果接收的参数是一个类的实例,则返回这个实例所有的实例变量,对应的类的类变量, ...
- JavaScript学习 - 基础(五) - string/array/function/windows对象
String对象 更详细转:http://www.w3school.com.cn/jsref/jsref_obj_string.asp //------------------------------ ...
- java 多线程三
java 多线程一 java 多线程二 java 多线程三 java 多线程四 注意到 java 多线程一 中 MyThread2 运行结果出现0.-1,那是因为在操作共享数据时没有加锁导致. 加锁的 ...
- 之手算KD-tree
转自:https://zhuanlan.zhihu.com/p/27453420 本文来源于Machine Learning: Clustering & Retrieval | Courser ...
- 使用SSH远程登陆Linux
⒈SSH介绍 SSH(Secure Shell)由IETF的网络工作小组(NetWork Working Group)所制定,SSH是建立在应用层和传输层基础上的安全协议. SSH是目前较可靠,专为远 ...