摘要: for(i=0; i<m; i++) { int x,y,son1,son2; scanf("%d %d",&x,&y); son1=x; son2=y; while(a[x]!=x) x=a[x];... 阅读全文
posted @ 2015-11-15 14:52 大领主 阅读(105) 评论(0) 推荐(0) 编辑
摘要: #include #include #include #include #include #include#includeusing namespace std;char s[100000];int flog=0;struct tree{ char a; struct tree *lef... 阅读全文
posted @ 2015-11-08 21:33 大领主 阅读(309) 评论(0) 推荐(0) 编辑
摘要: 不修正的kmp书写while(i<n) { if(j==-1||a[i]==a[j]) { i++,j++; // if(a[i]==a[j])next[i]=next[j]; ... 阅读全文
posted @ 2015-11-06 22:01 大领主 阅读(148) 评论(0) 推荐(0) 编辑
摘要: Assume the coasting is an infinite straight line. Land is in one side of coasting, sea in the other. Each small island is a point locating in the sea ... 阅读全文
posted @ 2015-10-28 19:39 大领主 阅读(139) 评论(0) 推荐(0) 编辑
摘要: 最近刚学了个map容器,头文件#include<map> 引用 map<string,int >vist;代表装入字符串,map缺省值为0; 当然也可以这样 char s1[300],s2[300],s3[300],s4[300]; vist[s4]=1;代表把字符串放进map中,查询时只要容器有s 阅读全文
posted @ 2015-10-20 20:54 大领主 阅读(146) 评论(0) 推荐(0) 编辑
摘要: 优先队列不同于普通队列,它分为最大优先队列和最小优先队列,当你写成priority_queuea时,它默认为最大优先队列最大优先队列即,当它用 a.top()时 从队列中寻找最大的数值,当它用 a.pop()时 从队列中删除最大的数值,#include #include #include #incl... 阅读全文
posted @ 2015-10-10 16:15 大领主 阅读(178) 评论(0) 推荐(0) 编辑
摘要: Advanced Cargo Movement, Ltd. uses trucks of different types. Some trucks are used for vegetable delivery, other for furniture, or for bricks. The com... 阅读全文
posted @ 2015-09-28 18:52 大领主 阅读(256) 评论(0) 推荐(0) 编辑
摘要: 我写的博客都是用c语言写的,易懂,重在理解 在做这道题的时候,我很无奈,看着别人做,自己却没思路,很无奈,In a word,一句话,是没有理解好bfs的后果 bfs相当于在头点,上下左右,寻找能走的路,最终以找到终点为目地。 bfs相当于二叉树中的层次遍历,需要用到栈 一个每块地板标记着0~9某个 阅读全文
posted @ 2015-08-12 18:25 大领主 阅读(570) 评论(0) 推荐(0) 编辑
摘要: A hat’s word is a word in the dictionary that is the concatenation of exactly two other words in the dictionary. You are to find all the hat’s words i 阅读全文
posted @ 2015-08-06 17:36 大领主 阅读(142) 评论(0) 推荐(0) 编辑
摘要: int a[10],i,b[10],t; for(i=0;i<10;i++) scanf("%d",&a[i]); b[0]=a[0]; for(i=1;i<10;i++) b[i]=max(b[i-1]+a[i],a[i]); 再用选择排序法求数组b 的最大值 阅读全文
posted @ 2015-07-11 09:36 大领主 阅读(193) 评论(0) 推荐(0) 编辑