随笔分类 -  数据结构---Trie树

摘要:题意:实现Trie class TrieNode{ public: bool isword; TrieNode* nex[26]; TrieNode():isword(false){ for(int i = 0; i < 26; ++i) nex[i] = NULL; } }; class Trie 阅读全文
posted @ 2020-04-02 15:55 Somnuspoppy 阅读(165) 评论(0) 推荐(0)
摘要:一、模板 结构体 struct Trie{ int val; Trie *nex[26]; Trie(){ val = 0; for(int i = 0; i < 26; ++i) nex[i] = NULL; } }; 建树 void build(string x, Trie *root){ in 阅读全文
posted @ 2020-03-23 14:49 Somnuspoppy 阅读(202) 评论(0) 推荐(0)
摘要:题意:给定n个字符串和m个经过处理得到的字符串,问对于m个字符串中的每个字符串,n个字符串中以该字符串为前缀的个数。分析:1、误差在[0.95x, 1.05x],因此求8个数的平均数,大于平均数为1,否则为0。2、字典树求前缀个数。 #include<cstdio> #include<cstring 阅读全文
posted @ 2017-07-31 21:08 Somnuspoppy 阅读(184) 评论(0) 推荐(0)