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 ...
随机推荐
- Java基础编程题——分别统计出其中汉字、英文字母、空格、数字和其它字符的个数
package com.yangzl.basic; import java.util.Scanner; /** * 分别统计出其中汉字.英文字母.空格.数字和其它字符的个数 * @author Adm ...
- QPushButton按钮
需要 from PyQt5.QtWidgets import QPushButton继承 QAbstractButton 创建按钮控件:QPushButton() 创建一个无父控件的按钮控件QPush ...
- strstr函数字符串匹配问题
题目链接:http://acm.sdut.edu.cn/onlinejudge2/index.php/Home/Index/problemdetail/pid/2772.html AC代码: #inc ...
- win7防火墙端口开放
https://jingyan.baidu.com/article/f96699bbadafca894f3c1b7a.html
- 升级版updateOozie.sh
以前的版本检测当天的Tar包,并只能选择1个Tar包进行更新代码,当天生成多个版本时需修改脚本中配置,并不方便. 升级版兼容目录下存在一个或者多个Tar包的情况: 1.单个Tar包时,直接解压缩到当前 ...
- Linux版本Membase无法写入default bucket的问题分析
最近项目中使用的membase发现出了点问题,生产环境中读写各种数据都正常,可是新搭建的开发环境下,只有default bucket写不进去数据,调用store总是返回FALSE,配置文件也是一模一样 ...
- sipML5聊天功能实现
一.环境说明:在阅读sipML5的API文档时,发现它具有聊天的功能,于是在sipML5的源码中进行设定,实现了注册之后可以英文聊天(中文聊天需要在FreeSWITCh中进行设定). 二.具体配置: ...
- Expm 9_1 有向图中环的判断问题
[问题描述] 给定一个有向图,要求使用深度优先搜索策略,判断图中是否存在环. package org.xiu68.exp.exp9; public class Exp9_1 { //用深度优先搜索判断 ...
- 如何从现有版本升级到element UI2.0?使用npm-check-updates
转:https://blog.csdn.net/wojiaomaxiaoqi/article/details/78428738 登录element UI官网时提示2.0已经正式发布了,Element ...
- 用Kotlin破解Android版微信小游戏-跳一跳
前言 微信又更新了,从更新日志上来看,似乎只是一次不痛不痒的小更新.不过,很快就有人发现,原来微信这次搞了个大动作——在小程序里加入了小游戏.今天也是朋友圈被刷爆的缘故. 看到网上 有人弄了一个破解版 ...