字典树水题。 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
字典树。 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 using namespace std; 8 9 typedef struct Trie { 10 int in;...
分类:
其他好文 时间:
2014-07-10 00:25:58
阅读次数:
378
字典树。 1 #include 2 #include 3 #include 4 5 #define MAXN 50005 6 #define MAXL 25 7 8 typedef struct Trie { 9 bool f;10 Trie *next[26];11 ...
分类:
其他好文 时间:
2014-07-07 21:20:46
阅读次数:
181
题目:
链接:点击打开链接
题意:
输入n,给出n行数据,每行有两个字符串,输出关系网络中朋友的个数,n行。
思路:
代码:
#include
#include
#include
#include
using namespace std;
const int N = 22;
const int M = 200020;
st...
分类:
其他好文 时间:
2014-07-01 08:14:07
阅读次数:
189
字典树+并查集。 1 #include 2 #include 3 #include 4 5 #define MAXN 500005 6 #define MAXL 11 7 #define TRIEN 26 8 9 typedef struct Trie { 10 ...
分类:
其他好文 时间:
2014-06-30 12:36:50
阅读次数:
224
字典树。 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 8 #define TRIEN 56 9 10 typedef struct Trie {11 Trie *n...
分类:
其他好文 时间:
2014-06-30 11:39:28
阅读次数:
210
DFS+字典树。题目数据很BT。注意控制DFS深度小于等于len。当'\0'时,还需判断末尾*。另外,当遇到*时,注意讨论情况。 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 usin...
分类:
其他好文 时间:
2014-06-29 18:41:17
阅读次数:
160
静态字典树。 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