摘要: http://livearchive.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=3735给了二叉树的先序遍历给成后续遍历。。解题: 分而治之。。View Code #include<iostream>#include<string.h>#include<algorithm>#include<stdio.h>using namespace std;const int maxn=100000;int n 阅读全文
posted @ 2012-10-05 00:16 一把刷子 阅读(222) 评论(0) 推荐(0) 编辑
摘要: 尼玛。。 一个 long long 调了 两天 。。解题:我们 可以沿着某一条从1到n的路线走下去,看能否找到合适的答案。。剪枝就是:1: 走过的不在走 记忆话搜索。。2: 如果某一点不是k的约数或者大于k或者和前面相等,不在往下走。。注意:因为k的约数的范围可能特别大,数组放不下,所以用map哈希。。用vector建立邻接表。。View Code #include<iostream>#include<string.h>#include<stdio.h>#include<algorithm>#include<map>#include& 阅读全文
posted @ 2012-10-04 10:56 一把刷子 阅读(246) 评论(0) 推荐(0) 编辑
摘要: http://codeforces.com/problemset/problem/229/C解题:应该是数学,高中数学白学了用C(3,n) - 被破坏了三角形数;对于在m中的每一个点统计它的出度。。那么 i点和它的任意一个出度点 和 下平面(m在上平面)构成了 出度总数*1*(n-1-出度总数)View Code #include<iostream>#include<stdio.h>#include<algorithm>#include<string.h>using namespace std;const int maxn=1000010;int 阅读全文
posted @ 2012-10-03 01:01 一把刷子 阅读(194) 评论(0) 推荐(0) 编辑
摘要: http://codeforces.com/contest/229/problem/A开始的时候有了思路,不会写了,捏麻麻的。。求出从正方向和逆方向使得一个坐标为1的最小步数,然后统计每一列为1的步数,求出最小值就是了。View Code #include<iostream>#include<string.h>#include<stdio.h>#include<algorithm>using namespace std;int dp[110][10010];int p[110][10010];char s[110][10010];int sum[ 阅读全文
posted @ 2012-10-02 16:32 一把刷子 阅读(205) 评论(0) 推荐(0) 编辑
摘要: http://codeforces.com/contest/230/problem/D解题思路:求最短路,如果到了那个在t时刻到了i点 且有人的话,就dis++;spfa 求解, 用了set ,vector,queue ,fill 加强了对c++函数的学习。基于spfa的:View Code #include<iostream>#include<stdio.h>#include<string.h>#include<algorithm>#include<queue>#include<vector>#include<se 阅读全文
posted @ 2012-10-02 16:26 一把刷子 阅读(220) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=4417你妹妹的 cin cout scanf printf.是差了好远呀,cin cout 会wa但scanf printf就ac了。。了解了eaual_range()的神奇操作。。做法就是线段树,vector很强大。。View Code #include<iostream>#include<cstdio>#include<algorithm>#include<vector>#define lson l,m,root<<1#define rson m 阅读全文
posted @ 2012-09-24 20:05 一把刷子 阅读(174) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=4414sb题啊,我wa了好久,你妹妹。。就是暴力枚举,然后我的方法是在检查每一位的时候检查他的相邻位,是否符合条件,队友的方法是后面来次dfs、、其实都一样。。View Code #include<iostream>#include<stdio.h>#include<string.h>#include<algorithm>using namespace std;char map[100][100];void init(int len){ for(int i=0; 阅读全文
posted @ 2012-09-24 18:43 一把刷子 阅读(132) 评论(0) 推荐(0) 编辑
摘要: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=4811首先肯定是KMP。然后刚开始想的是每删一次,做一次kmp,但是那样肯定会超时,所以就想一种可以利用了之前kmp信息的数据结构,看了一下别人的报告,知道了是栈这一种数据结构。然后每一次取出栈的最顶端就可以了。关于kmp,在说几句。我自己的设置的next数组的信息是当,当前位匹配失效是 ,他应该跳到哪一位去继续匹配。这里的当前位匹配失效指的是 s1当前位的下一位和s2的第i位不等。View Code #include<iostream>#include<s 阅读全文
posted @ 2012-09-22 10:49 一把刷子 阅读(242) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=2059很显然的加血的那种类型的题目,比赛遇过一次。看上面这个图,就是到达每站的时候,把可能通过其他方式到达该站的时间都算出来,然后取最小值,View Code #include<iostream>#include<string.h>#include<stdio.h>#include<algorithm>#define maxn 10000#define inf ~0U>>1using namespace std;int dis[maxn];doubl 阅读全文
posted @ 2012-09-18 23:57 一把刷子 阅读(265) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=2571就是很普通的根据题意递推了。不过题意有个坑的地方,有负值。所以初始化必须为-inf。被坑了好长时间。另外 不知道为什么 define 负数就错的 ,非得 改成 const int inf 。以后就这样用吧。和以前比赛做的那个走格子几乎是同样的。View Code #include<iostream>#include<string.h>#include<stdio.h>#include<algorithm>#define maxnconst int inf= 阅读全文
posted @ 2012-09-18 23:48 一把刷子 阅读(159) 评论(0) 推荐(0) 编辑