夏夜、

心若平似镜、何题不AC。

10 2013 档案

HDU 2243 AC自动机+DP+矩阵
摘要:好综合的一题啊,AC自动机+DP+非递归矩阵快速幂+二分+逆向思维。//#pragma comment(linker, "/STACK:1024000000,1024000000")#include#include#include#include#include#include#include#include#include#include#include#include#include#includeusing namespace std;typedef long long ll;typedef unsigned long long ull;typedef pair pi 阅读全文

posted @ 2013-10-22 16:44 BMan、 阅读(196) 评论(0) 推荐(0)

POJ 2779 DNA Sequence AC自动机+DP+矩阵
摘要:因为一个感叹号WA了一页//#pragma comment(linker, "/STACK:1024000000,1024000000")#include#include#include#include#include#include#include#include#include#include#include#include#include#includeusing namespace std;typedef long long ll;typedef pair pii;#define pb(a) push_back(a)#define INF 0x1f1f1f1f#de 阅读全文

posted @ 2013-10-21 22:31 BMan、 阅读(188) 评论(0) 推荐(0)

HDU 4686 Arc of Dream 矩阵快速幂
摘要:输入的数据会大于mod,当n=0时输出0.#include#include#include#include#include#include#include#includeusing namespace std;typedef long long ll;const ll mod = 1000000007;struct Matrix{ ll da[5][5]; Matrix (){memset(da,0,sizeof(da));} Matrix operator *(const Matrix &a) { Matrix res; for(int i... 阅读全文

posted @ 2013-10-21 13:33 BMan、 阅读(211) 评论(0) 推荐(0)

POJ 3233 Matrix Power Series 矩阵快速幂
摘要:if(n%2==0)s(n)=s(n/2)+s(n/2)*A^(n/2)else s(n)=s((n-1)/2)+s((n-1)/2)*A^((n-1)/2) + A^n。//#pragma comment(linker, "/STACK:1024000000,1024000000")#include#include#include#include#include#include#include#include#include#include#include#include#include#includeusing namespace std;typedef long lo 阅读全文

posted @ 2013-10-20 00:02 BMan、 阅读(188) 评论(0) 推荐(0)

UVA 11468 - Substring AC自动机+DP
摘要:dp[i][l]表示在结点i再走l步不碰到单词结点的概率。关键一步:val[u]|=val[fail[u]];#include#include#include#include#include#include#includeusing namespace std;const int MAX_NODE=444;const int SIGMA_SIZE=62;struct ACAutomation{ int sz; int fail[MAX_NODE]; int ch[MAX_NODE][SIGMA_SIZE]; int val[MAX_NODE]; double dp... 阅读全文

posted @ 2013-10-19 10:28 BMan、 阅读(260) 评论(0) 推荐(0)

UVA 1449 - Dominating Patterns AC自动机
摘要:因为有重复,结点用vector保存单词编号。#include#include#include#include#include#include#includeusing namespace std;const int MAX_NODE=15000;const int SIGMA_SIZE=26;struct ACAutomation{ int sz; int ch[MAX_NODE][SIGMA_SIZE]; int fail[MAX_NODE]; vector val[MAX_NODE]; void init() { sz=1; ... 阅读全文

posted @ 2013-10-18 16:48 BMan、 阅读(199) 评论(0) 推荐(0)

HDU 2896 病毒侵袭 AC自动机
摘要://#pragma comment(linker, "/STACK:1024000000,1024000000")#include#include#include#include#include#include#include#include#include#include#include#include#include#includeusing namespace std;typedef long long ll;typedef pair pii;#define pb(a) push_back(a)#define INF 0x1f1f1f1f#define lson id 阅读全文

posted @ 2013-10-17 17:58 BMan、 阅读(140) 评论(0) 推荐(0)

HDU 3065 病毒侵袭持续中 AC自动机
摘要://#pragma comment(linker, "/STACK:1024000000,1024000000")#include#include#include#include#include#include#include#include#include#include#include#include#include#includeusing namespace std;typedef long long ll;typedef pair pii;#define pb(a) push_back(a)#define INF 0x1f1f1f1f#define lson id 阅读全文

posted @ 2013-10-17 17:57 BMan、 阅读(199) 评论(0) 推荐(0)

HDU 2222 Keywords Search AC自动机
摘要:单词会重复,累加完一个的单词后把val清0,避免重复计算。//#pragma comment(linker, "/STACK:1024000000,1024000000")#include#include#include#include#include#include#include#include#include#include#include#include#include#includeusing namespace std;typedef long long ll;typedef pair pii;#define pb(a) push_back(a)#define 阅读全文

posted @ 2013-10-16 20:33 BMan、 阅读(168) 评论(0) 推荐(0)

POJ 3461 Oulipo KMP模板题
摘要:找来测代码//#pragma comment(linker, "/STACK:1024000000,1024000000")#include#include#include#include#include#include#include#include#include#include#include#include#include#includeusing namespace std;typedef long long ll;typedef pair pii;#define pb(a) push_back(a)#define INF 0x1f1f1f1f#define ls 阅读全文

posted @ 2013-10-14 17:26 BMan、 阅读(162) 评论(0) 推荐(0)

POJ 1226 Substrings KMP
摘要:KMP.暴力strstr也轻松过.//#pragma comment(linker, "/STACK:1024000000,1024000000")#include#include#include#include#include#include#include#include#include#include#include#include#include#includeusing namespace std;typedef long long ll;typedef pair pii;#define pb(a) push_back(a)#define INF 0x1f1f1f 阅读全文

posted @ 2013-10-10 21:29 BMan、 阅读(139) 评论(0) 推荐(0)

UVA 1455 Kingdom 线段树+并查集
摘要:并查集维护:y的最大最小值、城市数量线段树维护:城市数量,洲数量合并两个集合时,先在线段树上删除两个子集合的旧的信息,然后再将合并完的新集合更新到线段树。//#pragma comment(linker, "/STACK:1024000000,1024000000")#include#include#include#include#include#include#include#include#include#include#include#include#include#includeusing namespace std;typedef long long ll;typ 阅读全文

posted @ 2013-10-09 15:43 BMan、 阅读(225) 评论(0) 推荐(0)

UVA 11525 Permutation 康拓展开
摘要://#pragma comment(linker, "/STACK:1024000000,1024000000")#include#include#include#include#include#include#include#include#include#include#include#include#include#includeusing namespace std;typedef long long ll;typedef pair pii;#define pb(a) push_back(a)#define INF 0x1f1f1f1f#define lson id 阅读全文

posted @ 2013-10-09 13:59 BMan、 阅读(216) 评论(0) 推荐(0)

断剑重铸之日、骑士归来之时。
摘要:差不多一个月没切题了。。。。捂脸... 阅读全文

posted @ 2013-10-09 13:55 BMan、 阅读(135) 评论(0) 推荐(0)

导航