Trie
文章平均质量分 71
Drenight
Dream in the night.
展开
-
"strcmp()" Anyone? UVA - 11732 左孩子右兄弟Trie/计数
#include using namespace std; #define ll long long const int maxnode = 4000 * 1000 + 10; const int sigma_size = 26; // 字母表为全体小写字母的Trie struct Trie { int head[maxnode]; // head[i]为第i个结点的左儿子编号 int翻译 2017-05-17 21:17:39 · 225 阅读 · 0 评论 -
Kanade's trio 2017多校#3 trie
求数组中i 枚举插入ak,让ak中每一位作为最高位,查找字典树内最高位不同的数字数量 注意把ak的每个前缀做一个bad标记 存储让这个前缀作为i可以与字典树内形成i,j对的个数,这些不满足i #include //#pragma comment(linker, "/STACK:1024000000,1024000000") #include #include #include #incl原创 2017-08-09 18:58:05 · 195 阅读 · 0 评论 -
Xor Sum HDU - 4825 异或字典树模板
#include //#pragma comment(linker, "/STACK:1024000000,1024000000") #include #include #include #include #include #include #include #include #include #include using namespace std; #define ll long long原创 2017-08-09 20:56:34 · 265 阅读 · 0 评论 -
The xor-longest Path POJ - 3764 字典树异或
//#include //#pragma comment(linker, "/STACK:1024000000,1024000000") #include #include #include #include #include #include #include #include #include #include using namespace std; #define ll long lon原创 2017-08-09 22:18:17 · 169 阅读 · 0 评论 -
UVALive 3942 Trie加速dp
参考http://blog.csdn.net/qq_24489717/article/details/50832001 Trie树模板题 Trie树很好的把子串重复部分利用起来,一遍遍历可以用到多个单词节点的信息 转移方程:DP[i]=sum{DP[i+len(x)] | x为S[i……L]的前缀} 从小到大枚举原串后缀S 在Trie树中匹配后缀串,每到达一个单词节点就让DP【S原创 2017-05-17 16:51:33 · 245 阅读 · 0 评论 -
Codeforces 861D - Polycarp's phone book 字典树/hash
输入7e4个字符串,要求每个串提取一个子串来唯一表示 4s题可以hash暴力水过,大体思路就是把所有子串map自己的母串,过程中如果这个子串已有hash值就标-1 然后枚举map元素,维护最小化一下就行了 唯一要注意的就是十进制哈希方式区分不了00和0 另一种做法是字典树存下所有子串, 枚举母串,枚举子串,字典树删掉子串,树中查子串个数是不是0,是的话维护一下最小就行了 复杂度胜在字典原创 2017-09-20 15:25:37 · 288 阅读 · 0 评论 -
Codeforces Round #367 (Div. 2) Vasiliy's Multiset 异或字典树带删除模板
多重集版的异或字典树,拿之前的板子改改就交了 莫名wa7,回忆一波代码意义之后感觉没问题啊 读读题发现这个多重集里居然永远有0 。。。 赛中debug出来还是挺开心的原创 2017-11-22 03:19:52 · 163 阅读 · 0 评论 -
数组字典树模板
拿之前题解当模板的通用性太差了。。还是存个母版作为改的基础比较好暂时懒得学内存池,就都用数组版本吧全局要把trie[0].init()一次struct NODE{ int nxt[10]; int val; void init(){ val=0;memset(nxt,-1,sizeof nxt); } }trie[maxn]; int node_cnt=0; void insert(...原创 2017-09-20 14:22:01 · 260 阅读 · 0 评论