单链表----递归建立,递归反转,递归打印
摘要:/** auther: Try86* time:2012/9/25 13:14* dec:单链表:递归建立,递归反转,递归打印*/#include <stdio.h>#include <stdlib.h>#include <assert.h>typedef struct list //单链表节点结构{ int data; struct list *p_next;}List;int main(void){ int num = 0; //统计单链表的节点数 List *head = NULL; ...
阅读全文
posted @
2012-09-25 13:18
Try86
阅读(1142)
推荐(0)
hdu 2896(AC自动机)
摘要:1 #include <cstdio> 2 #include <cstring> 3 #include <cstdlib> 4 #include <iostream> 5 6 using namespace std; 7 8 const int N = 205; 9 const int L = 10005; 10 const int M = 100010; 11 12 int ans[5]; 13 char pat[N], str[L]; 14 struct node { 15 int n; 16 node *prefix; 17 node *.
阅读全文
posted @
2012-05-12 20:20
Try86
阅读(325)
推荐(0)
hdu 2222(AC自动机)
摘要:参考:http://www.cppblog.com/mythit/archive/2009/04/21/80633.html 1 /* 2 * AC自动机 3 */ 4 #include <cstdio> 5 #include <cstdlib> 6 #include <cstring> 7 #include <iostream> 8 9 using namespace std;10 11 const int N = 51;12 const int L = 500001;13 const int M = 1000001;14 15 char pa
阅读全文
posted @
2012-05-09 13:03
Try86
阅读(190)
推荐(0)
hdu 3172(并查集+字典树映射)
摘要:1 /* 2 * 并查集+字典树 3 */ 4 5 #include <cstdio> 6 #include <cstdlib> 7 #include <cstring> 8 #include <iostream> 9 10 using namespace std;11 12 const int N = 21;13 const int M = 200005;14 15 int cs;16 int parent[M];17 char strA[N], strB[N];18 struct node {19 int c;20 node *child[5
阅读全文
posted @
2012-05-08 18:27
Try86
阅读(376)
推荐(0)
hdu 1671(字典树)
摘要:1 /* 2 * 字典树 3 */ 4 #include <cstdio> 5 #include <cstring> 6 #include <cstdlib> 7 #include <iostream> 8 9 using namespace std;10 11 const int N = 11;12 13 bool yes;14 char str[N];15 struct node {16 bool flag;17 node *child[10];18 node() {19 flag = false;20 for (int i=...
阅读全文
posted @
2012-05-08 07:11
Try86
阅读(141)
推荐(0)
hdu 1247(字典树)
摘要:1 /* 2 * 字典树 3 * 思路:把所有单词建成一棵字典树,然后把每个分成两部分,判断这两部分是否在树中 4 * 是,就符合条件。 5 */ 6 7 #include <cstdio> 8 #include <cstdlib> 9 #include <cstring>10 #include <iostream>11 12 using namespace std;13 14 const int N = 16;15 const int M = 50005;16 17 char strL[N], strR[N], dic[M][N]; 18 st
阅读全文
posted @
2012-05-08 07:03
Try86
阅读(739)
推荐(0)
hdu 1251(字典树)
摘要:1 /* 2 * 字典树 3 */ 4 #include <cstdio> 5 #include <cstdlib> 6 #include <cstring> 7 #include <iostream> 8 9 using namespace std;10 11 const int N = 11;12 13 char str[N];14 struct node {//节点数据 15 int c; //统计前缀个数 16 node *child[26];17 node() {//初始化 18 c = 1;19 for (int i...
阅读全文
posted @
2012-05-07 21:52
Try86
阅读(124)
推荐(0)
hdu 1232(并查集)
摘要:/* Name: 并查集 Author: Try_86 Date: 10/04/12 20:11*/#include <cstdio>#include <iostream>using namespace std;const int M = 1000;int p[M], sum;void init(int n) { for (int i=1; i<=n; ++i) p[i] = i; return ;}int find(int x) { if (p[x] != x) p[x] = find(p[x]); return p[x];}void join(int x, .
阅读全文
posted @
2012-04-10 20:12
Try86
阅读(180)
推荐(0)