摘要: 求一个串至少包含k个给定的串的方案数(k个串可相互覆盖-所以只能用AC自动机了)状态压缩使每个串唯一(1#include#include#include#include#include#include#include#include#include#include#include#define tree int o,int l,int r#define lson o q;//保存的节点下标 f[0]=0; for (int c=0; c>1)+(x&1));}int dp(int u,int sub,int num){ if(sub==n) return bit... 阅读全文
posted @ 2013-10-17 20:04 baoff 阅读(276) 评论(0) 推荐(0) 编辑
摘要: 问你长度为1~N的串中包含了模式串的串总共有几个(先求出总共小于L的单词数(26^1+26^2+26^3+...26^L)..然后再减去不包括所给字符串的单词)答案要模2^64,直接用unsinged __int64!!!!算法:AC自动机+二分求等比矩阵和+二分求等比数列和(ps:等比矩阵求和(或等比数列),有经典算法,假定原矩阵为A,阶数为n,那么构造一个阶数为2n的矩阵,如下| AE |其中O代表O矩阵,E代表单位矩阵,这样,求出的K次矩阵的右上n子矩阵正好是| OE |等比矩阵的K项和,这种构造法比我实现的两次二分快了4倍左右。这里有个错误要注意...求出K次矩阵的右上子矩阵应该是K- 阅读全文
posted @ 2013-10-17 17:36 baoff 阅读(219) 评论(0) 推荐(0) 编辑
摘要: //#pragma comment(linker, "/STACK:102400000")#include#include#include#include#include#include#include#include#include#include#include#include#define tree int o,int l,int r#define lson o q;//保存的节点下标 f[0]=0; for (int c=0; c<M; ++c ) { int u=ch[0][c]; if(u)//不需要优化的else { ... 阅读全文
posted @ 2013-10-17 11:27 baoff 阅读(422) 评论(0) 推荐(0) 编辑
摘要: 参考:http://hi.baidu.com/ccsu_010/item/7847a3c17f6fe2bc0d0a7b89关键是状态转移,矩阵就是解决状态转移的!(比较难)数据量:1 #include#include#include#include#include#include#include#include#include#include#include#define tree int o,int l,int r#define lson o q;//保存的节点下标 f[0]=0; for (int c=0; c>=1; } memcpy(ma,temp,sizeof... 阅读全文
posted @ 2013-10-17 10:22 baoff 阅读(250) 评论(0) 推荐(0) 编辑