随笔分类 -  DFA

poj 3691
摘要:ac自动机+dp#include<iostream>#include<fstream>using namespace std;struct e{ int p[5]; int end;}trie[1001];int n,m,K;int hash[300];int state=1;int f[1001];void build(char c[]){ int i,j=0,k; for(i=1;;) { if(trie[i].p[hash[c[j]]]==0) trie[i].p[hash[c[j]]]=++state; i=trie[i].p[hash[c[j]]]; j++; 阅读全文

posted @ 2011-03-15 13:54 宇宙吾心 阅读(669) 评论(0) 推荐(0)

poj 2778
摘要:自动机+矩阵乘。代码:#include<iostream>#include<fstream>using namespace std;struct e{ int p[5]; int end;}trie[101];int m,K,n;int hash[128];int state=1;long long s;int f[101];void build(char c[]){ int i,j=0,k; for(i=1;;) { if(trie[i].p[hash[c[j]]]==0) trie[i].p[hash[c[j]]]=++state; i=trie[i].p[hash 阅读全文

posted @ 2011-03-09 15:26 宇宙吾心 阅读(1158) 评论(0) 推荐(1)

poj 1625
摘要:ac自动机+高精+dp高精输出适用了cout.wide cout.fill('0');代码:#include<iostream>#include<fstream>using namespace std;struct e{ int p[51]; int end;}trie[501];int n,m,K;int hash[600];int state=1;int f[501];void build(char c[]){ int i,j=0,k; for(i=1;;) { if(trie[i].p[hash[c[j]]]==0) trie[i].p[hash[ 阅读全文

posted @ 2011-03-08 15:30 宇宙吾心 阅读(840) 评论(0) 推荐(0)

导航