摘要: http://acm.hdu.edu.cn/showproblem.php?pid=4198 今天杭电热身赛的B题,读完题就上手写dfs,结果爆栈了,500*500的规模对暴力递归来说有点多。 然后就是bfs,遇到@时先放入另一队列,当当前step>que[head].step时que[head]入队(这里可以证明que[head]的step是que总的最小值)。第一个出口便为最终解。 思路就这样,结果写出来各种bug各种蛋疼。最后直接调晕了...code:#include<cstdio>#include<cstring>#defineMin(a,b)a>b 阅读全文
posted @ 2012-04-03 19:57 追逐. 阅读(375) 评论(1) 推荐(1) 编辑
摘要: http://www.bianchengla.com/practise/problem?id=1387 第一道后缀数组,求出最大的height值即可。更多的是当个模板用吧。code:#include<cstdio>//最长重复子串#include<cstring>constintmaxn=10001;intwa[maxn],wb[maxn],wv[maxn],ws[maxn],rank[maxn],height[maxn],sa[maxn],s[maxn];charstr[maxn];intcmp(int*r,inta,intb,intl){returnr[a]==r[ 阅读全文
posted @ 2012-04-03 19:25 追逐. 阅读(253) 评论(0) 推荐(0) 编辑