【题目链接】:

https://loj.ac/problem/10052

【题意】:

就是给一些串,是否存在两个串是相同前缀的。

【题解】

模板题,不想解释了。

【代码】:

 #include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std ;
typedef long long ll;
const int N = 1e4;
int Son[N][];
char str[N][];
int n,idx;
bool f,cnt[N];
void Insert(char s[]){
int p = ;
for(int i=;s[i];i++){
int t = s[i] - '';
if( !Son[p][t] ) Son[p][t] = ++idx;
p = Son[p][t] ;
}
cnt[p] = true;
}
void Query(char s[]){
int p = ;
for(int i=;s[i+];i++){
int t = s[i] - '' ;
if( !Son[p][t] ) break;
p = Son[p][t];
if( cnt[p] ) f = true;
}
}
void Init(){
f = false;
idx = ;
memset(Son,,sizeof Son);
memset(cnt,false,sizeof cnt);
}
int main()
{
int kase = ;
while(~scanf("%s",str[n])){
if( !strcmp( str[n],"") ){
//printf("######### %d ######### \n",n);
Init();
for(int i=;i<n;i++){
Insert(str[i]);
}
for(int i=;i<n;i++){
Query(str[i]);
}
n = ;
printf("Set %d is",++kase);
puts(!f?" immediately decodable":" not immediately decodable");
}else{
n ++ ;
}
}
return ;
}

【Trie】Immediate Decodability的更多相关文章

  1. 【Trie】背单词

    参考博客: https://www.luogu.org/problemnew/solution/P3294 https://blog.csdn.net/VictoryCzt/article/detai ...

  2. 【Trie】L 语言

    [题目链接]: https://loj.ac/problem/10053 [题意]: 给出n个模式串.请问文本串是由多少个模式串组成的. [题解]: 当我学完AC自动机后,发现这个题目也太简单了吧. ...

  3. 【Trie】Nikitosh 和异或

    [参考博客]: LOJ#10051」「一本通 2.3 例 3」Nikitosh 和异或(Trie [题目链接]: https://loj.ac/problem/10051 [题意]: 找出两个不相交区 ...

  4. 【Trie】Phone List

    [题目链接]: https://loj.ac/problem/10049 [题意] 问是否存在一组公共前缀.如果存在输出“NO”,否则输出“YES” [题解] 首先建出Trie树来,然后开始记录所有的 ...

  5. 【Trie】The XOR-longest Path

    [题目链接]: https://loj.ac/problem/10056 [题意] 请输出树上两个点的异或路径  的最大值. [题解] 这个题目,y总说过怎么做之后,简直就是醍醐灌顶了. 我们知道Xo ...

  6. 【Trie】Secret Message 秘密信息

    [题目链接]: https://loj.ac/problem/10054 [题意] 我认为这个题目最难的是题意: 其实分了两种情况: 1.如果当前文本串匹配不完,那么答案的是:匹配过程中遇到的模式串结 ...

  7. 【Trie】The XOR Largest Pair

    [题目链接] https://loj.ac/problem/10050 [题意] 给出n个数,其中取出两个数来,让其异或值最大. [题解] 经典的01字典树问题. 首先需要把01字典树建出来. 然后对 ...

  8. 【Trie】模板(动态指针,静态数组)

    摘自hackbuteer1 Trie树,又称单词查找树或键树,是一种树形结构,是一种哈希树的变种.典型应用是用于统计和排序大量的字符串(但不仅限于字符串),所以经常被搜索引擎系统用于文本词频统计.它的 ...

  9. 【Trie】【HDU1247】【Hat’s Wordsfd2】

    题目大意: hat's word 的定义是字典中 恰好由另外两个单词连接起来的单词 给你一本字典,问有多少个hat's word,(字典按字典序给出) 单词数50000.. 初步思路: 单词分为前缀单 ...

随机推荐

  1. 什么是Servlet容器?

    在本文中,我写了一些关于Web服务器.Servlet容器以及它与JVM的关系的基本概念.我想表达的是,Servlet容器也仅仅不过是一个Java程序. 1. 什么是Web服务器? 想要知道什么是Ser ...

  2. 自定义镜像mycentos

    1.编写 1).Hub默认CentOS镜像是什么情况 2).编写Dockerfile文件 2.构建 3.运行

  3. Windows下使用cmd运行jar文件

    一般window系统下是不能直接运行jar文件的.(有些电脑可以,记得我以前的电脑是双击jar就可以运行的) 那么如何在windows下运行jar呢? 1.首先,电脑必须配置java运行环境jre-- ...

  4. 第11组 Alpha冲刺(4/6)

    第11组 Alpha冲刺(4/6)   队名 不知道叫什么团队 组长博客 https://www.cnblogs.com/xxylac/p/11884529.html 作业博客 https://edu ...

  5. Default Keyboard Shortcut Schemes

    Default Keyboard Shortcut Schemes All ReSharper actions can be invoked with keyboard shortcuts. Most ...

  6. Infralution.Localization.Wpf

    WPF Localization Using RESX Files Once you have downloaded the source code and built it, add a refer ...

  7. Oracle中shrink space命令

    shrink_clause:   http://docs.oracle.com/cd/B19306_01/server.102/b14200/statements_3001.htm#i2192484 ...

  8. 论好的代码习惯的养成/做一个优雅的coder

    1.先说一下以前被滴滴大佬教育的事情: 以前写代码的时候,因为只需要取特定的几个字段,所以经常这么写 //Request $request for example $parameters = $req ...

  9. js和微信小程序本地获取东八北京时间

    changeCount(){ // 目标时区,东8区 const targetTimezone = -8; // 当前时区与中时区时差,以min为维度 const dif = new Date().g ...

  10. [Java复习] Spring 常见面试问题

    1. 什么是 Spring 框架?Spring 框架有哪些主要模块? 轻量级实现IoC和AOP的JavaEE框架. Core模块: bean(bean定义创建解析), context(环境, IoC容 ...