摘要: Algorithm X通过回溯找到答案。 阅读全文
posted @ 2014-10-24 12:00 Mr.Youyu 阅读(92) 评论(0) 推荐(0)
摘要: 题意求包含模板的长度小于等于L的单词个数。N和L的范围 感觉是构造矩阵。然后开始想状态:对于所有模板建立AC自动机,这样得到每个节点的是否可以包含模板串,构造矩阵。答案=总数-合法数。对L加1 会超出int范围。代码丑的醉了、 1 #include 2 #include 3 #includ... 阅读全文
posted @ 2014-10-23 23:28 Mr.Youyu 阅读(152) 评论(0) 推荐(0)
摘要: 统计 模板串出现的总数。 1 #include 2 #include 3 #include 4 #include 5 6 #define MAXN 1100010 7 #define SIG 26 8 using namespace std; 9 10 struct A... 阅读全文
posted @ 2014-10-23 17:12 Mr.Youyu 阅读(180) 评论(0) 推荐(0)
摘要: 后缀数组经常用于求 LCP, 于是看到LCP就直接用后缀数组。n^2的动态规划就可以完成对所有对的LCP求解,真是Orz! 阅读全文
posted @ 2014-10-03 23:06 Mr.Youyu 阅读(257) 评论(0) 推荐(0)
摘要: 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 using namespace std; 8 9 const int N = 210;10 const int M=1001000;11 const... 阅读全文
posted @ 2014-10-01 20:00 Mr.Youyu 阅读(207) 评论(0) 推荐(0)
摘要: 详细 百度百科。例子hdu 2586 1 #pragma comment(linker, "/STACK:16777216") 2 #include 3 #include 4 #include 5 #include 6 7 using namespace std; 8 9 const i... 阅读全文
posted @ 2014-09-17 19:42 Mr.Youyu 阅读(220) 评论(0) 推荐(0)
摘要: 区间第k大 1 #include 2 #include 3 #include 4 #include 5 #define MID ((l+r)>>1) 6 using namespace std; 7 8 const int N=100500; 9 10 int a[N],s[N],t[20... 阅读全文
posted @ 2014-09-16 17:44 Mr.Youyu 阅读(122) 评论(0) 推荐(0)
摘要: 求Σ|x-xi| 最小,只要求得这个区间的中位数t,然后numl*t-suml+sumr-numr*t (如果是偶数个 任意取中间一个)。求区间中位数,可以用划分树,suml 即区间内比中位数小的数的和,也可以同时求出来。 1 #include 2 #include 3 #include ... 阅读全文
posted @ 2014-09-16 16:29 Mr.Youyu 阅读(117) 评论(0) 推荐(0)
摘要: 参考资料:百度百科 1 #include 2 #include 3 #include 4 using namespace std; 5 6 #define N 100500 7 8 #define MID ((l+r)>>1) 9 int a[N],s[N],t[2... 阅读全文
posted @ 2014-09-16 16:18 Mr.Youyu 阅读(131) 评论(0) 推荐(0)
摘要: 因为一看到有关子串就主动的联想后缀数组所有后缀的前缀去重后就是所有子串(好像是废话)这样就可以得到每个后缀的子串个数。二分查找到第k个所在的位置。在二分处理所有可以出现该串的sa区间。最小就是维护sa数组。 1 //rank从0开始 2 //sa从1开始,因为最后一个字符(最小的)排在第0位 ... 阅读全文
posted @ 2014-09-15 13:11 Mr.Youyu 阅读(589) 评论(0) 推荐(0)