摘要:
模板来源:http://www.neroysq.com/?p=76思路:http://blog.sina.com.cn/s/blog_7812e98601012dfv.html题意就是求两个字符串的最长公共子串,串长最大250000。以串A构建一个后缀自动机,用串B来匹配。枚举串B的每一位B[i]即考虑串B中所有以B[i]为结尾的子串,维护的值为以B[i]为末尾能匹配的最大长度tmpL。假设走到B[i]时已经匹配好的串为str,如果当前节点有B[i]这个儿子,直接向下走,++tmpL。如果没有,沿着fail指针向前回退,直到找到一个有B[i]儿子的节点。#include #include #i 阅读全文
posted @ 2013-08-04 21:11
冰鸮
阅读(241)
评论(0)
推荐(0)
摘要:
昨天跟后缀自动机死磕了一下午,也没搞明白怎么回事。今天又把网上找到的资料重新看了一遍,顿时觉得一道大闪电从后脑劈过——好像突然有点明白了orz……不过只能说目前勉强明白了后缀自动机是如何构建的,对于它的很多性质和用法,还有待学习。本人弱菜一只,如有错误,欢迎指正~本文只是后缀自动机构建过程的演示图,不负责解释理论部分。如果想看证明或者解释,推荐以下资料:陈立杰课件:http://wenku.baidu.com/view/7afa5828ed630b1c59eeb512.html(这个真没看懂……)构建演示+解释说明http://www.neroysq.com/?p=76http://fanhq 阅读全文
posted @ 2013-08-04 17:36
冰鸮
阅读(2748)
评论(0)
推荐(3)
摘要:
没刷过,从各个地方搜刮来的,留底备用HDU 4641HDU 4622HDU 4436HDU 4416HDU 3518codeforces 235Ccodeforces 271Dcodeforces 127DPOJ 1509SPOJ 1811SPOJ 1812SPOJ NSUBSTRSPOJ SUBLEXSPOJ LCSSPOJ LCS2 阅读全文
posted @ 2013-08-04 15:22
冰鸮
阅读(326)
评论(0)
推荐(0)
摘要:
给你N的一个排列,求满足:a[i] 2 #include 3 #include 4 #include 5 6 #define LL long long int 7 8 using namespace std; 9 10 const int MAXN = 100100;11 const LL MOD = 100000007;12 13 int N;14 int C[MAXN];15 int num[MAXN];16 int low[MAXN];17 int high[MAXN];18 19 int lowbit( int x )20 {21 return x & ( -x )... 阅读全文
posted @ 2013-08-04 14:41
冰鸮
阅读(211)
评论(0)
推荐(0)
摘要:
一共才100个正方形,将所有正方形左下角和右上角的X坐标和Y坐标离散化,直接枚举新建公园的点的坐标即可。O(n^3)的时间复杂度。 1 #include 2 #include 3 #include 4 #include 5 6 using namespace std; 7 8 const int MAXN = 110; 9 const int INF = 255; 10 11 struct Land 12 { 13 int x, y; 14 int len; 15 int import; 16 }; 17 18 int N, K, M;... 阅读全文
posted @ 2013-08-04 10:12
冰鸮
阅读(279)
评论(0)
推荐(0)

浙公网安备 33010602011771号