随笔分类 -  数据结构

吝啬的国度 简单的图搜索
摘要:1 #include <stdio.h> 2 #include <string.h> 3 #include <math.h> 4 #include <stdlib.h> 5 int pre[100005]; 6 typedef struct edge 7 { 8 int v; 9 struct ed 阅读全文

posted @ 2016-05-04 11:26 青春的梦想付诸行动 阅读(148) 评论(0) 推荐(0)

红黑树
摘要:1 #include <cstdio> 2 #include <iostream> 3 #include <cstring> 4 #include <cmath> 5 using namespace std; 6 struct node { 7 int l,r; 8 }; 9 node s[10]; 阅读全文

posted @ 2016-04-21 16:03 青春的梦想付诸行动 阅读(145) 评论(0) 推荐(0)

等式 hash
摘要:刚开始想都不用想用了暴力 当然超时。 根据题目要求10000k内存 一般64m内存即可以通过 利用hash函数建立,时间通过。但内存超出了。。。代码1 1 2 3 #include <cstdio> 4 #include <cstring> 5 using namespace std; 6 7 sh 阅读全文

posted @ 2016-04-20 15:12 青春的梦想付诸行动 阅读(176) 评论(0) 推荐(0)

士兵杀敌二 (树状数组)
摘要:1 #include <cstdio> 2 #include <cstring> 3 using namespace std; 4 5 int a[1000010],c[1000010]; 6 int N,M; 7 8 int lowbit(int x) 9 { 10 return x&(-x); 阅读全文

posted @ 2016-04-19 20:04 青春的梦想付诸行动 阅读(107) 评论(0) 推荐(0)

士兵杀敌 一
摘要:1 #include <cstdio> 2 #include <algorithm> 3 #include <cstring> 4 using namespace std; 5 int n,m,s[1000010],x,y; 6 7 int main() 8 { 9 scanf("%d%d",&n, 阅读全文

posted @ 2016-04-19 14:53 青春的梦想付诸行动 阅读(115) 评论(0) 推荐(0)

括号配对问题
摘要:1 #include <cstdio> 2 #include <cstring> 3 #include <queue> 4 #include <stack> 5 #include <algorithm> 6 #include <cmath> 7 using namespace std; 8 9 st 阅读全文

posted @ 2016-04-15 11:09 青春的梦想付诸行动 阅读(126) 评论(0) 推荐(0)

KMP AC自动机算法
摘要:在KMP算法中,为了确定在匹配不成功时,下次匹配时j的位置,引入了next[]数组,next[j]的值表示P[0...j-1]中最长后缀的长度等于相同字符序列的前缀。 对于next[]数组的定义如下: 1) next[j] = -1 j = 0 2) next[j] = max(k): 0<k<j 阅读全文

posted @ 2016-02-24 13:35 青春的梦想付诸行动 阅读(421) 评论(0) 推荐(0)

汉若塔问题(递归)
摘要:1 #include <iostream> 2 #include <stdio.h> 3 using namespace std; 4 5 static int step = 0; 6 void move ( char sour, char dest ) 7 { 8 printf ( "move f 阅读全文

posted @ 2016-02-12 23:10 青春的梦想付诸行动 阅读(189) 评论(0) 推荐(0)

POJ Wormholes 最短路径 ballman_ ford 有负环
摘要:1 #include <cstdio> 2 #include <cstring> 3 #include <algorithm> 4 #include <iostream> 5 #include <queue> 6 #define MAX 9999999 7 8 using namespace std 阅读全文

posted @ 2016-01-30 23:18 青春的梦想付诸行动 阅读(379) 评论(0) 推荐(0)

最短路径 Dijkstra && Bellman_ford
摘要:1 #include<cstdio> 2 #include<iostream> 3 #include<algorithm> 4 #include<queue> 5 #include<cstring> 6 #define MAX 9999999 7 8 using namespace std; 9 1 阅读全文

posted @ 2016-01-26 19:43 青春的梦想付诸行动 阅读(206) 评论(0) 推荐(0)

导航