2013年6月20日

摘要: 亲戚题:已知a和b是亲戚,a和c是亲戚,则可以判断出b和c也是亲戚。将多个集合合并成没有交集的集合。 1 #include <iostream> 2 using namespace std; 3 4 int N, M, Q; 5 int pre[20000], rak[20000]; 6 7 void MakeSet(int x) 8 { 9 pre[x] = -1;10 rak[x] = 0;11 }12 13 int FindSet(int x)14 {15 int r = x, q;16 while (pre[r] != -1)17 r... 阅读全文
posted @ 2013-06-20 11:02 月moon鸟 阅读(161) 评论(0) 推荐(0) 编辑
摘要: Trie,又称单词查找树或键树,是一种树形结构,是一种哈希树的变种。利用字符串的公共前缀来降低查询时间的开销以达到提高效率的目的。可以统计词频或是判断是否是前缀。1000万的广告库关键词,来一个查询词,找出是查询词子集的关键词集合。 1 #include <stdio.h> 2 #include <string.h> 3 #include <stdlib.h> 4 5 #define MAX 256 6 #define MAXLEN 256 7 8 typedef struct _TrieNode 9 {10 int count;11 struct _Tri 阅读全文
posted @ 2013-06-20 10:50 月moon鸟 阅读(229) 评论(0) 推荐(0) 编辑

导航