字典树水题。 1 #include 2 #include 3 #include 4 5 typedef struct Trie { 6 bool v; 7 Trie *next[2]; 8 } Trie; 9 10 Trie *root;11 12 bool create(c...
分类:
其他好文 时间:
2014-07-10 14:20:40
阅读次数:
199
简单字典树。 1 #include 2 #include 3 #include 4 5 #define MAXN 128 6 7 typedef struct Trie { 8 int count; 9 Trie *next[MAXN];10 Trie() {11 ...
分类:
其他好文 时间:
2014-07-10 13:43:34
阅读次数:
239
XorSumProblemDescriptionZeus和Prometheus做了一个游戏,Prometheus给Zeus一个集合,集合中包括了N个正整数,随后Prometheus将向Zeus发起M次询问,每次询问中包括一个正整数S,之后Zeus须要在集合其中找出一个正整数K,使得K与S的异或结果最...
分类:
其他好文 时间:
2014-06-28 10:15:04
阅读次数:
224
静态字典树。 1 #include 2 #include 3 #include 4 5 #define MAXN 10005 6 7 typedef struct Trie { 8 bool v; 9 Trie *next[10];10 Trie() {11 ...
分类:
其他好文 时间:
2014-06-28 09:39:33
阅读次数:
171
1.引言
题目的意思应该是:在一个给定的字典中,求与给定的字符串的编辑距离不大于2的所有的单词。原先写过两片关于此问题的文章,那两片篇章文章给出两种解决思路:其一是暴力求解法,这种方法最容易想到。就是将词典中的词一一与给定的字符串计算编辑距离,不大于2的输出,大于2的舍弃,这种方法思路简单但是很费时间。其二根据词典中这些词之间的编辑距离建立一个以单词为节点的Trie树,遍历的...
分类:
其他好文 时间:
2014-06-27 23:31:21
阅读次数:
241
DFS+字典树。 1 #include 2 #include 3 #include 4 5 typedef struct Trie { 6 int v; 7 Trie *next[26]; 8 } Trie; 9 10 Trie root; 11 int ...
分类:
其他好文 时间:
2014-06-27 14:32:44
阅读次数:
183
字典树简单题。 1 #include 2 #include 3 #include 4 5 typedef struct Trie { 6 Trie *next[26]; 7 char str[15]; 8 } Trie; 9 10 Trie root;11 12 void c...
分类:
其他好文 时间:
2014-06-27 11:32:27
阅读次数:
172
数组实现的Trie树 字符容量有限,可以使用链表实现更为大容量的Trie
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;
#define sigma_size 26
#define...
分类:
其他好文 时间:
2014-06-26 11:57:16
阅读次数:
349
这题看是否这题能A是侥幸,解决的办法是先存一下输入的字符串,进行排序。Problem DescriptionAn encoding of a set of symbols is said to be immediately decodable if no code for one symbol is...
分类:
其他好文 时间:
2014-06-25 11:46:47
阅读次数:
248
#include #include #include #include using namespace std; typedef struct Node { struct Node *next[10]; int flag; }Node,*Tree; int flag1; void Cre...
分类:
其他好文 时间:
2014-06-25 11:27:43
阅读次数:
154