题目链接点这里

题意:

  让你构造一个长度范围在[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. 第一章:systemverilog简介

    1.为何要学systemverilog ..... 2.systemverilog起源 ..... 3.systemverilog标准历程 systemverilog3.0 for 综合 system ...

  2. Spring Boot Web开发中Thymeleaf模板引擎的使用

    这里使用的是idea 1.新建Spring Boot项目 File-->New-->Project...,然后选择左边的Spring Initializr-->Next,可根据自己的 ...

  3. jquery ajax示例

    $.ajax({ type: "POST",//方法类型 dataType: "json",//预期服务器返回的数据类型 url: "${ctx }/ ...

  4. POJ 3620 Avoid The Lakes (求连接最长的线)(DFS)

    Description Farmer John's farm was flooded in the most recent storm, a fact only aggravated by the i ...

  5. PS学习笔记(04)

    Photoshop滤镜的安装 Photoshop滤镜的默认格式为.8bf(也有些滤镜为exe格式的可执行文件),如果你下载的是压缩包,请解压之后再安装. 方法一: 如果你下载的滤镜为exe的可执行文件 ...

  6. xtu summer individual 2 E - Double Profiles

    Double Profiles Time Limit: 3000ms Memory Limit: 262144KB This problem will be judged on CodeForces. ...

  7. 生物遗传学 整理人PYJ (恋_紫花地丁)

    生物遗传学整理人PYJ (恋_紫花地丁) 高中生物唯一需要数学知识的就是遗传学的概率计算了.这里对简单的遗传学规律做一些总结. 目录: 1.      孟德尔第一定律(分离定律): 2.      孟 ...

  8. 【尺取】HDU String

    http://acm.hdu.edu.cn/showproblem.php?pid=5672 [题意] 给定一个小写英语字母组成的字符串,求这个字符串一共包含多少个至少有m个不同字母的连续子序列 [思 ...

  9. Codeforces Round #533 (Div. 2) E 最大独立集

    知识点 最大独立集(set) = 补图的最大团(clique ) 最小顶点覆盖 + 最大独立集 = V E. Helping Hiasat time limit per test 2 seconds ...

  10. 【nginx】【转】Nginx启动框架处理流程

    Nginx启动过程流程图: ngx_cycle_t结构体: Nginx的启动初始化在src/core/nginx.c的main函数中完成,当然main函数是整个Nginx的入口,除了完成启动初始化任务 ...