题目链接点这里

题意:

  让你构造一个长度范围在[A,B]之间 字符串(大小写字母,数字),问你有多少种方案

  需要满足条件一下:

    1:构成串中至少包含一个数字,一个大写字母,一个小写字母;

      2:不能包含给定的N个病毒串

3:遵循一堆映射规则

题解:

  将病毒串建立AC自动机

  设定dp[i][j] [0/1][0/1][0/1]:表示构造长度为i,在自动机上面的状态是j,分别是否含有数字,大写字母,小写字母的情况

  你能转移的点就是 加上一个数字或者大小写字母,暴力转移DP就好了,方程复杂度:20*1000*8,转移复杂度:26+26+10

  整体复杂度:20*1000*8*62+建立trie

#include<bits/stdc++.h>
using namespace std;
#define ls i<<1
#define rs ls | 1
#define mid ((ll+rr)>>1)
#define pii pair<int,int>
#define MP make_pair
typedef long long LL;
const long long INF = 1e18+1LL;
const double Pi = acos(-1.0);
const int N = 1e6+, M = 1e3+;
LL mod = ;
int nex[][],q[],fail[],cnt=,black[],head,tail;
int rea_ID(int ch) {
if(ch >= && ch < ) return ch;
if(ch == ) return 'o'-'a';
if(ch == ) return 'i'-'a';
if(ch == ) return 'e'-'a';
if(ch == ) return 's'-'a';
if(ch == ) return 't'-'a';
if(ch >= && ch <= ) return ;
if(ch > && ch <= )return ch - ;
}
int ID(char ch) {
return ch - 'a';
}
void insert(char *s) {
int now = , len = strlen(s);
for(int i = ; i < len; ++i) {
int index = ID(s[i]);
if(!nex[now][index])
nex[now][index] = ++cnt;
now = nex[now][index];
}
black[now] |= ;
}
void build_fail() {
head = , tail = ;
for(int i = ; i < ; ++i) nex[][i] = ;
fail[] = ;
q[tail++] = ;
while(head != tail) {
int now = q[head++];
black[now] |= black[fail[now]];
for(int i = ; i < ; ++i) {
int p = fail[now];
if(!nex[now][i]) {
nex[now][i] = nex[p][i];continue;
}
fail[nex[now][i]] = nex[p][i];
q[tail++] = nex[now][i];
}
nex[now][] = ;
}
}
int A,B,n;
char s[];
LL dp[][][][][];
int main()
{
scanf("%d%d",&A,&B);
scanf("%d",&n);
for(int i = ; i <= n; ++i) {
scanf("%s",s);
insert(s);
}
build_fail();
dp[][][][][] = ;
for(int i = ; i <= B; ++i) {
for(int j = ; j <= cnt; ++j) {
for(int dxziok = ; dxziok <= ; ++dxziok)
for(int shuziok = ; shuziok <= ; ++shuziok)
for(int xxziok = ; xxziok <= ; ++xxziok) {
if(dp[i][j][dxziok][shuziok][xxziok] == ) continue;
for(int k = ; k <= ; ++k) {
int rea = rea_ID(k);
int tmp1 = ,tmp2 = ,tmp3 = ;
if(k < ) tmp1 = ;
else if(k <= ) tmp2 = ;
else tmp3 = ;
if(!black[nex[j][rea]])
dp[i+][nex[j][rea]][dxziok|tmp1][shuziok|tmp2][xxziok|tmp3] +=
dp[i][j][dxziok][shuziok][xxziok];
dp[i+][nex[j][rea]][dxziok|tmp1][shuziok|tmp2][xxziok|tmp3]%=mod;
}
} }
}
LL ans = ;
for(int i = A; i <= B; ++i) {
for(int j = ; j <= cnt; ++j) {
ans = (ans + dp[i][j][][][])%mod;
}
}
cout<<ans<<endl;
return ;
}

  

2016-2017 ACM-ICPC Southwestern European Regional Programming Contest (SWERC 2016) E.Passwords AC自动机+dp的更多相关文章

  1. Gym 2009-2010 ACM ICPC Southwestern European Regional Programming Contest (SWERC 2009) A. Trick or Treat (三分)

    题意:在二维坐标轴上给你一堆点,在x轴上找一个点,使得该点到其他点的最大距离最小. 题解:随便找几个点画个图,不难发现,答案具有凹凸性,有极小值,所以我们直接三分来找即可. 代码: int n; lo ...

  2. 2016-2017 ACM-ICPC Southwestern European Regional Programming Contest (SWERC 2016) F dfs序+树状数组

    Performance ReviewEmployee performance reviews are a necessary evil in any company. In a performance ...

  3. 2016-2017 ACM-ICPC Southwestern European Regional Programming Contest (SWERC 2016)

    A. Within Arm's Reach 留坑. B. Bribing Eve 枚举经过$1$号点的所有直线,统计直线右侧的点数,旋转卡壳即可. 时间复杂度$O(n\log n)$. #includ ...

  4. 2016-2017 ACM-ICPC Southwestern European Regional Programming Contest (SWERC 2016) B - Bribing Eve

    地址:http://codeforces.com/gym/101174/attachments 题目:pdf,略 思路: 把每个人的(x1,x2)抽象成点(xi,yi). 当1号比i号排名高时有==& ...

  5. 2016-2017 ACM-ICPC Southwestern European Regional Programming Contest (SWERC 2016) D.Dinner Bet 概率DP+排列组合

    题目链接:点这里 题意: 1~N标号的球 现在A有C个,B有C个 每次可以随机得到D个不同的球(1~N);问你A或B中的C个球都出现一次的 期望次数 题解: dp[i][j][k]表示 随机出现了i个 ...

  6. 2017-2018 ACM-ICPC Southwestern European Regional Programming Contest (SWERC 2017)

    A. Cakey McCakeFace 按题意模拟即可. #include<stdio.h> #include<iostream> #include<string.h&g ...

  7. 2016-2017 ACM-ICPC Northwestern European Regional Programming Contest (NWERC 2016)

    A. Arranging Hat $f[i][j]$表示保证前$i$个数字有序,修改了$j$次时第$i$个数字的最小值. 时间复杂度$O(n^3m)$. #include <bits/stdc+ ...

  8. 2016-2017 ACM-ICPC Southeastern European Regional Programming Contest (SEERC 2016)

    题目链接  Codefores_Gym_101164 Solved  6/11 Penalty Problem A Problem B Problem C Problem D Problem E Pr ...

  9. 2017-2018 ACM-ICPC Southeastern European Regional Programming Contest (SEERC 2017)

    2017-2018 ACM-ICPC Southeastern European Regional Programming Contest (SEERC 2017) 全靠 wxh的博客 补完这套.wx ...

随机推荐

  1. Linux用户和组的概念

    目 录 第1章 用户和组存在的关系    1 1.1 我们现在所使用的操作系统都是多用户操作系统    1 1.2 id命令查看当前登陆的用户信息    1 1.3 用户UID的分类    1 1.4 ...

  2. 条款32:确定你的public继承塑模出is-a 关系(Make sure public inheritacne models "is-a")

    NOTE : 1."public继承"意味is-a.适用于base classes  身上的每一件事一定也适用于derived classes身上,因为每一个derived cla ...

  3. 【HDU 6153】A Secret (KMP)

    Problem Description Today is the birthday of SF,so VS gives two strings S1,S2 to SF as a present,whi ...

  4. 【Codeforces 1141E】Superhero Battle

    [链接] 我是链接,点我呀:) [题意] 题意 [题解] 二分最后轮了几圈. 二分之后直接o(N)枚举具体要多少时间即可. 注意爆long long的情况. 可以用对数函数,算出来有多少个0 如果大于 ...

  5. cf839c Journey

    大水题 #include <iostream> #include <cstdio> using namespace std; int n, du[100005], hea[10 ...

  6. kissy学习

    http://docs.kissyui.com/1.4/docs/html/guideline/kmd.html

  7. jmeter-添加断言(检查点)-实例

    方法/步骤     打开 jmeter的图形界面工具,然后打开之前保存的脚本(之前经验中用到的),demo-baidu.jmx   先点击运行,查看运行结果. 第一次请求返回302,然后跳转到第二次请 ...

  8. Jquery跨域请求

    在JavaScript中,有一个很重要的安全性限制,被称为“Same- Origin Policy”(同源策略).这一策略对于JavaScript代码能够访问的页面内容做了很重要的限制,即JavaSc ...

  9. C 题 KMP中next[]问题

    题目大意: 找到能够进行字符串匹配的前缀 这题只要一直求next,直到next为0停止,记得答案是总长减去next的长度 #include <iostream> #include < ...

  10. HDU 6035 (虚树)(统计颜色)

    HDU 6035 Colorful Tree Problem : 给一棵树,每个结点有一种颜色,定义每条路径的权值为这条路径上颜色的种数,询问所有路径(C(n,2)条)的权值之和. Solution ...