05 2014 档案

 
XMU 1246
摘要:http://acm.xmu.edu.cn/JudgeOnline/problem.php?id=1246求区间内素数个数,经典问题,区间长度10^6,数的取值最多能到10^12(此题范围稍小)用筛法搞出[2,根号b]范围内的素数,用这些素数再去筛[a,b]一个吐血的trick,1不是素数#incl... 阅读全文
posted @ 2014-05-30 18:56 LegendaryAC 阅读(210) 评论(0) 推荐(0)
km算法
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2255km模板,二分图最优匹配,复杂度O(n^3)http://www.cnblogs.com/jackge/archive/2013/05/03/3057028.html#include #include #in... 阅读全文
posted @ 2014-05-21 15:24 LegendaryAC 阅读(234) 评论(0) 推荐(0)
HDU 1358
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1358求某个前缀的周期,用Next求循环节的题目#include #include #include #include using namespace std ;char B[1000005] ;int Next[... 阅读全文
posted @ 2014-05-20 21:35 LegendaryAC 阅读(147) 评论(0) 推荐(0)
HDU 3746
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=3746kmp的Nxet数组求字符串循环节例题lenB%(lenB-Next[lenB])==0则其有周期lenB/(lenB-Next[lenB]),其中最小循环节长度是lenB-Next[lenB]#includ... 阅读全文
posted @ 2014-05-20 21:14 LegendaryAC 阅读(381) 评论(0) 推荐(0)
CF 432D
摘要:http://codeforces.com/problemset/problem/432/D在前缀是后缀的前提下,求这个前缀在原串中出现了多少次出现的次数可以用dp求解,前缀是后缀直接用Next判断,较为综合的kmp考察,这题没写出来就是kmp基础不牢,不应该#include #include #i... 阅读全文
posted @ 2014-05-20 20:14 LegendaryAC 阅读(322) 评论(0) 推荐(0)
HDU 4725
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=4725求1-n最短路,每个点有一个层数,相邻层之间花费k可以到达建图时把层数看成n个点,层到该层点距离为0,点到其相邻层距离为c,相邻层之间距离为c#include #include #include #inclu... 阅读全文
posted @ 2014-05-19 23:54 LegendaryAC 阅读(240) 评论(0) 推荐(0)
14年百度之星资格赛第四题
摘要:LabyrinthTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 519 Accepted Submission(s): 174Proble... 阅读全文
posted @ 2014-05-16 16:54 LegendaryAC 阅读(560) 评论(0) 推荐(0)
AC自动机
摘要:hdu2222 字符串多模匹配算法 采用kuangbin模板#include #include #include #include #include using namespace std;struct Trie{ int next[500010][26],fail[500010],end[5... 阅读全文
posted @ 2014-05-16 14:16 LegendaryAC 阅读(192) 评论(0) 推荐(0)
RMQ
摘要:数组下标0-n-1,询问区间最值int dp[100005][20];void makermq(int n, int *a) { for(int i = 0; i < n; i++) dp[i][0] = a[i]; for(int j = 1; (1<<j) <= n; ... 阅读全文
posted @ 2014-05-14 19:11 LegendaryAC 阅读(111) 评论(0) 推荐(0)
HDU 4635
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=4635问:最多加多少条边,使得原图不是强连通图正向考虑有困难,不妨反向思考,既最少去掉几条边使得原图不是强连通。总边数sum=n*(n-1)时肯定是强连通,已经给了m条边,sum-=m这时把已经强连通的部分进行缩点... 阅读全文
posted @ 2014-05-13 23:30 LegendaryAC 阅读(778) 评论(0) 推荐(0)
HDU 3667
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=3667最小费用最大流本题流量和费用不是线性关系,fee=a*flow*flow,所以常规套模板spfa无法得到最小费用观察到每条边流量上限只有5,则可以把一条流量为f的边拆成f条流量为1的边,每条边费用是a*(2*... 阅读全文
posted @ 2014-05-07 21:15 LegendaryAC 阅读(196) 评论(0) 推荐(0)
2-sat
摘要:http://blog.sina.com.cn/s/blog_64675f540100k2xj.htmlhttp://www.cppblog.com/MatoNo1/archive/2011/07/13/150766.aspx讲解看的这两篇博客,其实最好直接去看国家集训队的论文,别的抄来抄去想找个原... 阅读全文
posted @ 2014-05-07 17:22 LegendaryAC 阅读(153) 评论(0) 推荐(0)
HDU 3062
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=30622sat判定性问题模板#include #include #include #include #include #include using namespace std ;struct node { i... 阅读全文
posted @ 2014-05-07 13:55 LegendaryAC 阅读(213) 评论(0) 推荐(1)
HDU 2292
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2292题意:1-n个节点,题目给出了完全二叉树的定义(这个定义似乎有歧义,此题以题目描述为准),且要保持最小堆性质(根节点小于左右子树内的任意元素),问有多少种不同组合解法:dp,dp[n]表示n个元素的合法排列数... 阅读全文
posted @ 2014-05-07 11:53 LegendaryAC 阅读(178) 评论(0) 推荐(0)
最大流之dinic
摘要:先用bfs预处理出层次图,然后在层次图上用dfs找增广路径,理论复杂度O(n*n*m)const int INF=0xfffffff ;struct node{ int s,t,cap,nxt ;}e[400005] ;int m,n,cnt,head[100005],level[100005... 阅读全文
posted @ 2014-05-01 13:40 LegendaryAC 阅读(158) 评论(0) 推荐(0)