摘要: 纠结一晚上,注意细节啊!!!(看到有很多解题报告都用<queue>,我不太喜欢用STL的东西。。。)My Code:#include <iostream>#include <cstdio>#include <cstring>using namespace std;const int N = 51;struct node{ int x; int y; int z; int t;}q[N*N*N];int d[6][3] = {{1, 0, 0}, {-1, 0, 0}, {0, 1, 0}, {0, -1, 0}, {0, 0, -1}, {0, 阅读全文
posted @ 2011-08-22 22:05 AC_Von 阅读(322) 评论(0) 推荐(0) 编辑
摘要: 字典树(Trie树),可以将之归为高级数据结构吧,黑书上把Trie树和线段树一起讲的。之所以叫它字典树,大概是因为它的结构太像字典了。就像这张图片:由字符串 abcd、abd、bcd、efg、hi。建成的Trie树如上图所示(Trie树大概的结构一看就能理解);Trie树的主要操作:1、建立新节点(姑且算是一样吧);2、插入(建树);3、查找(与树中的字符串匹配,这个过程是肯快的,如果能完全匹配的时间复杂度为是O(n),n = strlen(s)。)Trie的实现:1、结构体定义:struct node{ int flag; //标记 node * next[26]; ... 阅读全文
posted @ 2011-08-22 09:00 AC_Von 阅读(667) 评论(0) 推荐(0) 编辑