文章目录
一、题目
- 一、题目
- 二、思路和代码
- 1.思路
- 2.代码
题目链接: hdu2825
是一道关于AC自动机和状压dp的好题 遇到10、15这样的数据范围需敏感,有可能就是状压dp 对trie树里的节点进行状压,也许也可以认为是一道树型dp(?)
2.代码代码如下:
#include
#include
#include
using namespace std;
const int mod = 20090717;
const int maxn = 111;
struct node {
int cnt;
int end;
int next[26];
node() {
memset(next, 0, sizeof(next));
cnt = 0;
end = 0;
}
void init() {
memset(next, 0, sizeof(next));
cnt = 0;
end = 0;
}
} trie[maxn];
int cnt;
int fail[maxn];
int n, m, _k, ans;
char str[15];
int dp[30][maxn][1
关注
打赏