Trie 树(字典树)
SSL_LKJ
蒟蒻一名 蒟蒻一名 蒟蒻一名 蒟蒻一名 蒟蒻一名 蒟蒻一名 蒟蒻一名 蒟蒻一名 蒟蒻一名 蒟蒻一名 蒟蒻一名 蒟蒻一名 蒟蒻一名 蒟蒻一名 蒟蒻一名 蒟蒻一名 蒟蒻一名 蒟蒻一名 蒟蒻一名 蒟蒻一名 蒟蒻一名 蒟蒻一名 蒟蒻一名 蒟蒻一名 蒟蒻一名 蒟蒻一名 蒟蒻一名 蒟蒻一名 蒟蒻一名 蒟蒻一名 蒟蒻一名 蒟蒻一名 蒟蒻一名 蒟蒻一名 蒟蒻一名 蒟蒻一名 蒟蒻一名 蒟蒻一名 蒟蒻一名 蒟蒻一名 蒟蒻一名 蒟蒻一名 蒟蒻一名 蒟蒻一名 蒟蒻一名 蒟蒻一名 蒟蒻一名 蒟蒻一名 蒟蒻一名 蒟蒻一名
展开
-
阅读理解(Trie 树)
阅读理解 解题思路 这题相比前两题较容易 可以用 Trie 树 和 一个数组存储 AC代码 #include<iostream> #include<cstdio> #include<bitset> using namespace std; int n,m,sum,t[500005][30]; bitset<1005>f[500005]; string s; void insert(int x) { int o=0,len=s.size(); for(原创 2021-04-16 20:37:17 · 49 阅读 · 0 评论 -
最长异或路径(Trie 树)
最长异或路径 解题思路 这题和最大异或对(字典树)很相似 AC代码 #include<iostream> #include<cstdio> using namespace std; int n,x,sum,tot,mmax,b[100005],c[100005],head[100005],t[10000005][2]; struct node { int to,next,w; }a[200005]; void add(int x,int y,int z) { a[++tot]原创 2021-04-16 20:31:39 · 64 阅读 · 0 评论 -
最大异或对(字典树)
最大异或对 解题思路 这题数据较大,可以用字典树+位运算 AC代码 #include<iostream> #include<cstdio> using namespace std; int n,x,sum,mmax,t[10000005][2]; void insert()//插入 { int o=0; for(int i=31;i>=0;i--) { int ch=(x>>i)&1; if(!t[o][ch])t[o][ch]=++sum;原创 2021-04-16 20:28:40 · 95 阅读 · 0 评论 -
前缀统计(字典树 Trie)
前缀统计 解题思路 这题就是字典树模板 字典树 AC代码 #include<iostream> #include<cstdio> using namespace std; int n,m,sum,c[1000005],t[1000005][30]; string s; void insert()//插入 { int o=0,len=s.size();//长度 for(int i=0;i<len;i++) { int ch=s[i]-'a'; if(!t[o][原创 2021-04-16 20:24:21 · 175 阅读 · 0 评论 -
Trie 树(字典树)讲解(P2580 于是他错误的点名开始了)
前言 因为在学Trie 树(字典树) 时没找到心仪的博客 就自己打了一篇 方便他人也方便自己 Trie(字典树) 我们先来看一道题 于是他错误的点名开始了 题目传送门 解题思路 首先看这题 就是问这些字符串有没有出现过而已 相信会有大部分同学选择map来做 但我们也可以用别的方法——(trie 树) trie 树讲解 Trie 树又称字典树 搬上百度百科的讲解 将字符串都储存在一棵树中 这棵树的节点都为一个字符 我们来看看这棵字典树 1.很显然,字典树是一课无根的树 2.同时,还能发现一个节点可原创 2021-04-03 09:38:15 · 1061 阅读 · 2 评论