摘要: "【SPOJ】Longest Common Substring II" 多个字符串求最长公共子串 还是将一个子串建SAM,其他字符串全部跑一边,记录每个点的最大贡献 由于是所有串,要对每个点每个字符串跑完后去最小值才是每个点的最终贡献 cpp include include include incl 阅读全文
posted @ 2018-12-31 12:07 y2823774827y 阅读(141) 评论(0) 推荐(0) 编辑
摘要: "【HDU4622】Reincarnation" 一眼似乎不可做,但发现$strlen(x)$很小,暴力$O(n^2)$预处理每个区间$(l,r)$,查询时$O(1)$输出就好了 cpp include include include include include typedef int LL; 阅读全文
posted @ 2018-12-31 10:15 y2823774827y 阅读(134) 评论(0) 推荐(0) 编辑
摘要: "P5112 FZOUTSY" 建个后缀自动机,当然这里得反着建 找到最小的大于k的子串,相当于最小满足的子串,$endpos$最大,然后沿$parents$边都染成同一色 同色的都满足后缀的最长公共前缀满足大于k,接下来就是莫队在树上跑 cpp include using namespace st 阅读全文
posted @ 2018-12-30 23:47 y2823774827y 阅读(136) 评论(0) 推荐(0) 编辑
摘要: "P4244 [SHOI2008]仙人掌图 II" 仙人掌求直径,和树一样最大+次大 处理环时,算一下环内两点距离+子树最大和,根节点此时的其他子树已确定的最大子树 用 环内一点距离+点最大子树更新 cpp include include include include using namespac 阅读全文
posted @ 2018-12-30 22:54 y2823774827y 阅读(184) 评论(0) 推荐(0) 编辑
摘要: "【SPOJ】Longest Common Substring" 求两个字符串的最长公共子串 对一个串建好后缀自动机然后暴力跑一下 ~~废话~~ 讲一下怎么跑吧 从第一个字符开始遍历,遍历不到了再沿着$parents$走看能否找到出路,走到某个点时,统计一下走过了多少点然后更新答案 来说说这样做的正 阅读全文
posted @ 2018-12-30 20:14 y2823774827y 阅读(199) 评论(0) 推荐(0) 编辑
摘要: "【SPOJ】Distinct Substrings" 求不同子串数量 统计每个点有效的字符串数量(第一次出现的) $\sum\limits_{now=1}^{nod}now.longest parents.longest$ My complete code cpp include using na 阅读全文
posted @ 2018-12-30 16:26 y2823774827y 阅读(182) 评论(0) 推荐(0) 编辑
摘要: "P4410 [HNOI2009]无归岛" 显然这还是一个仙人掌图 对于同一个岛上的任意两个生物,他们有且仅有一个公共朋友 要求求最大独立集,和树形dp一样,遇到环时单独提出来处理一下就好了 cpp include include include include include using name 阅读全文
posted @ 2018-12-30 15:37 y2823774827y 阅读(152) 评论(0) 推荐(0) 编辑
摘要: "P3180 [HAOI2016]地图" 显然,这是一个仙人掌图 cpp inline void tarjan(LL u,LL fa){ low[u]=dfn[u]=++tot, pre[tot]=u; for(LL i=head[u];i;i=dis[i].next){ LL v=dis[i].t 阅读全文
posted @ 2018-12-29 08:26 y2823774827y 阅读(112) 评论(0) 推荐(0) 编辑
摘要: "P2787 语文1(chin1) 理理思维" 第一眼似乎不可做,发现是字符,只有$26$个字母,暴力做一下就行 对于排序,查询每个字母出现次数,再区间一块一块放进去 My complete code include include include include using namespace s 阅读全文
posted @ 2018-12-28 23:19 y2823774827y 阅读(228) 评论(0) 推荐(0) 编辑
摘要: "P2221 [HAOI2012]高速公路" $n 1$条边,查询点$(l,r)l include include include include using namespace std; typedef long long LL; const LL maxn=1e7+1; inline LL Re 阅读全文
posted @ 2018-12-28 23:12 y2823774827y 阅读(147) 评论(0) 推荐(0) 编辑