2015年11月24日

BZOJ 2724: [Violet 6]蒲公英

摘要: 题目:http://www.lydsy.com/JudgeOnline/problem.php?id=2724分块+二分。 首先离散化,维护ans[i][j]表示第i块到第j块之间的众数,然后对于询问l,r,在完整块的我们拿出来,然后暴力扫非完整块。我们只要把相同的数排在一起,对于a[i],我们可以... 阅读全文

posted @ 2015-11-24 20:45 ctlchild 阅读(165) 评论(0) 推荐(0) 编辑

BZOJ4010: [HNOI2015]菜肴制作

摘要: 题目:http://www.lydsy.com/JudgeOnline/problem.php?id=4010求反图的拓扑排序并逆序输出之。用个priority_queue就可以了。#include#include#include#include#include#define rep(i,l,r) ... 阅读全文

posted @ 2015-11-24 14:11 ctlchild 阅读(163) 评论(0) 推荐(0) 编辑

BZOJ 2160: 拉拉队排练

摘要: 题目:http://www.lydsy.com/JudgeOnline/problem.php?id=2160构造完回文树后,从后往前扫一遍,令cnt[fail[i]]+=cnt[i],可得到每个串的出现次数。那么对于回文树中的一个结点,其长度为len[i],出现次数为cnt[i],那我们拿出前K个... 阅读全文

posted @ 2015-11-24 14:07 ctlchild 阅读(196) 评论(0) 推荐(0) 编辑

HDU-5157Harry and magic string

摘要: 题目:http://acm.hdu.edu.cn/showproblem.php?pid=5157先从后往前插点,在构造回文树时,让cnt[i]+=cnt[fail[i]],然后维护一个后缀和a。再从前往后插点,每个点对答案的贡献为cnt[i]*a[i+1]#include#include#incl... 阅读全文

posted @ 2015-11-24 14:02 ctlchild 阅读(226) 评论(0) 推荐(0) 编辑

HDU-5421Victor and String

摘要: 题目:http://acm.hdu.edu.cn/showproblem.php?pid=5421因为要在前面插字符,所以维护一个前缀链和后缀链,在同一棵回文树上搞,如果有某个最长回文后缀(或前缀)的长度为总长,那让前缀(或后缀)的last也赋为当前结点。#include#include#inclu... 阅读全文

posted @ 2015-11-24 13:58 ctlchild 阅读(211) 评论(0) 推荐(0) 编辑

导航