【题目链接】:

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. python数据分析与应用

    python数据分析与应用笔记 使用sklearn构建模型 1.使用sklearn转换器处理数据 import numpy as np from sklearn.datasets import loa ...

  2. [Windows]Visual Studio Code个人配置

    编辑器要添加的 settings.json 打开这个: { ,//编辑字号 "files.autoSave": "afterDelay",//自动保存 &quo ...

  3. easyui复选框实现单选框

    $(':checkbox[name=primary_key_flag]').each(function(){ $(this).click(function(){ if(this.checked){ $ ...

  4. go结构体的方法和普通函数

    package main import ( "fmt" "math" ) type vertex struct { X, Y float64 } //值接收者是 ...

  5. Java 线程概述

    1 进程与线程基本概念 1.1 进程:执行中的程序 每个进程都有独立的代码和数据空间(进程上下文),进程空间切换会有较大的开销,一个进程包含1-n个线程.进程是资源分配的最小单位. 1.2 线程:进程 ...

  6. java课后实验性问题1

    一.一个java类文件中只能有一个公有类吗? 测试代码 public class Test{ public static void main(String[] args){ } public clas ...

  7. SSH交互式脚本StrictHostKeyChecking选项 benchmode=yes

    SSH 公钥检查是一个重要的安全机制,可以防范中间人劫持等黑客攻击.但是在特定情况下,严格的 SSH 公钥检查会破坏一些依赖 SSH 协议的自动化任务,就需要一种手段能够绕过 SSH 的公钥检查. 什 ...

  8. rc.local 注意事項,call python script, file position

    如果要在 rc.local 呼叫 python script python script 的位置需使用絕對路徑 其 python script 裡的有關 file 的位置也需使用 絕對路徑 如果要在 ...

  9. centos中screen的使用

    只是讲解几个简单的操作,例如,创建新窗口,切换到新窗口,删除窗口.(因为我要启动elk,所以需要使用到screen) 一.创建一个新窗口: 安装完成后,直接敲命令screen就可以启动它.但是这样启动 ...

  10. exactly the kind of division of tasks that Gulp.js is built on

    The results are then passed to a reporter function that displays the results of the code analysis in ...