上一页 1 ··· 58 59 60 61 62 63 64 65 66 ··· 71 下一页
摘要: http://poj.org/problem?id=1068View Code 1 #include<stdio.h> 2 #include<string.h> 3 int stack[20001],top,b[10001]; 4 void inst(int x,int y) 5 { 6 int i; 7 for(i = top+1 ; i <= top+(x-y) ; i++) 8 stack[i] = 1; 9 top = top+x-y+1;10 stack[i] = 0;11 b[x] = top;12 }13 int main()14... 阅读全文
posted @ 2012-07-23 20:29 _雨 阅读(159) 评论(0) 推荐(0) 编辑
摘要: http://www.cplusplus.com/reference/stl/http://net.pku.edu.cn/~yhf/UsingSTL.htm#include<set>View Code 1 #include<iostream> 2 #include<set> 3 using namespace std; 4 int main() 5 { 6 int i,j,n,a; 7 cin>> n; 8 set <int> h;//定义一个h 9 for(i = 1 ;i <= n ; i++)10 {11 cin > 阅读全文
posted @ 2012-07-23 09:36 _雨 阅读(248) 评论(0) 推荐(0) 编辑
摘要: http://baike.baidu.com/view/8150013.htmhttp://acm.hdu.edu.cn/showproblem.php?pid=2222今天看到这道题 以为是KMP 刚学完 想拿来练手 谁知写完超时。去discuss看了看 说是用AC自动机过的 今天也没什么安排 就去了解了下 它是建立在KMP和trie树基础上的一种高效串匹配的算法先将字符串建成一个字典树 标记每个字符串的尾部 建完之后 输入待匹配的字符串 这是只对这个字符串进行循环查找即可 判断每个字符是否是在字典树里出现 当循环到一个字符串的尾部时 num就会加上这个字符串的数量。看着别人的模板打了一晚上 阅读全文
posted @ 2012-07-22 12:08 _雨 阅读(191) 评论(0) 推荐(0) 编辑
摘要: http://dongxicheng.org/structure/trietree/http://hi.baidu.com/piaoshi111/item/ad5f7c12ca63f38889a95622http://poj.org/problem?id=3630刚开始套字典树 将字符串末尾标记 查询到末尾时标记 动态的 超时了 参考着别人的写了个静态的 过了 172MSView Code 1 #include 2 #include 3 #include 4 using namespace std; 5 struct node 6 { 7 int count; 8 int n... 阅读全文
posted @ 2012-07-22 11:25 _雨 阅读(250) 评论(0) 推荐(0) 编辑
摘要: 就是判断有向图中是否有环 由于开始用dfs搜忘记return了 纠结了一下午 还是经虎学长指点 才找到错误递归View Code 1 #include<stdio.h> 2 #include<string.h> 3 int g[101][101],c[101]; 4 int dfs(int u,int n) 5 { 6 int v; 7 c[u] = -1; 8 for(v = 1 ; v <= n ; v++) 9 if(g[u][v])10 {11 if(c[v]<0)12 {13 ... 阅读全文
posted @ 2012-07-21 20:58 _雨 阅读(275) 评论(0) 推荐(0) 编辑
摘要: http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2142View Code 1 #include<stdio.h> 2 #include<string.h> 3 int q[5001]; 4 int d; 5 void inque(int x) 6 { 7 d++; 8 q[d] = x; 9 }10 int main()11 {12 int t,n,m,i,j,k,f[101][101],fg[101],a,b;13 scanf("%d",& 阅读全文
posted @ 2012-07-21 20:28 _雨 阅读(267) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1181一次AC 没什么细节要注意 就是输入正确 加上dfs 可以 了View Code 1 #include<stdio.h> 2 #include<string.h> 3 typedef struct node 4 { 5 char c[101]; 6 int f; 7 }st; 8 st q[1001]; 9 int flag;10 void dfs(int x,int n)11 {12 int i,j;13 if(flag)14 return ;15 ... 阅读全文
posted @ 2012-07-21 19:29 _雨 阅读(236) 评论(0) 推荐(0) 编辑
摘要: 堆排序 堆排序利用了大根堆(或小根堆)堆顶记录的关键字最大(或最小)这一特征,使得在当前无序区中选取最大(或最小)关键字的记录变得简单。 (1)用大根堆排序的基本思想 ① 先将初始文件R[1..n]建成一个大根堆,此堆为初始的无序区 ② 再将关键字最大的记录R[1](即堆顶)和无序区的最后一个记录R 阅读全文
posted @ 2012-07-21 09:37 _雨 阅读(314) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1180这题交了7次 悲剧了 前几次 因为把+行想成是左右走了 一直WA 后来看出来了 又把走过的楼梯给标记了 这里的楼梯不能标记因为可以在原地等着楼梯转变 加的时间有可能是2 这样普通队列满足不了最少的先搜 就用优先队列了View Code 1 #include<stdio.h> 2 #include<string.h> 3 typedef struct node 4 { 5 int x,y,num; 6 }st; 7 int f[22][22]; 8 char c[22][22]; 阅读全文
posted @ 2012-07-21 00:02 _雨 阅读(385) 评论(0) 推荐(0) 编辑
摘要: http://www.cppblog.com/shyli/archive/2007/04/06/21366.htmlstl中的优先队列的模板:#include priority_queue q;(队头为大,top为大)这是按照从大到小的队列;priority_queue, greater > q;这是从小到大的优先队列;#include struct cmp { bool operator ()(const int &i,const int &j) { return i>j; } }; http://acm.sdut.edu.cn/sdutoj/pro... 阅读全文
posted @ 2012-07-20 16:56 _雨 阅读(389) 评论(6) 推荐(0) 编辑
上一页 1 ··· 58 59 60 61 62 63 64 65 66 ··· 71 下一页