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 ...
随机推荐
- JS禁止右键查看源码,禁止复制,复制内容到剪切板
有时候我们希望自己的网页源码不被查看,这时需要关掉鼠标的右击事件;有时候我们也希望禁止选择页面内容Ctrl+C复制. 1.禁止右键查看源码; <script> //设置右键事件 funct ...
- 跟踪OceanLotus的新下载程序KerrDown
攻击的方法 两种方法将KerrDown下载器传递给目标.一个是使用带有恶意宏的Microsoft Office文档,另一个是包含带有DLL side-loading合法程序的RAR存档 .对于RAR存 ...
- T_RegionNDS表创建及值
-- Table structure for t_regionnds -- ---------------------------- DROP TABLE IF EXISTS t_regionnds; ...
- Qt Excel
在pro文件添加 QT +=axcontainer 头文件 #include <QAxObject> void MainWindow::on_btnSelectFileDialog_cli ...
- centos7使用haproxy1.7.5实现反向代理负载均衡实战
使用haproxy实现反向代理负载均衡实战环境准备:两台虚拟机 # yum install -y gcc glibc gcc-c++ make screen tree lrzsz node1源码编译安 ...
- python文件、文件夹操作OS模块
转自:python文件.文件夹操作OS模块 '''一.python中对文件.文件夹操作时经常用到的os模块和shutil模块常用方法.1.得到当前工作目录,即当前Python脚本工作的目录路径: ...
- Android 动画:你真的会使用插值器与估值器吗?
目录 目录 1. 插值器(Interpolator) 1.1 简介 定义:一个接口 作用:设置 属性值 从初始值过渡到结束值 的变化规律 如匀速.加速 & 减速 等等 即确定了 动画效果变 ...
- how to detect circles and rectangle?
opencv中对圆检测的函数为:HoughCircles(src_gray,circles,CV_HOUGHT_GRADIENT,1,src_gray.cols/8,200,100,0,0) circ ...
- --save-dev和--save的区别
使用npm来进行前端包管理的时候,我们会用到npm install或者cnpm install命令来安装需要用到的包资源 1: npm install *** --save-dev 2: npm in ...
- laravel 列表搜索查询(when,with用法以及关联图像id处理图像路径)
laravel中比较常规的列表查询: /** * 活动列表 * @param Request $request * @return \Illuminate\Http\JsonResponse */ p ...