poj 1625 Censored!//AC自动机+DP+大数
来源:互联网 发布:邦有道则知 邦无道则愚 编辑:程序博客网 时间:2024/05/16 13:41
Censored!
Time Limit: 5000MS Memory Limit: 10000KTotal Submissions: 3608 Accepted: 999
Description
The alphabet of Freeland consists of exactly N letters. Each sentence of Freeland language (also known as Freish) consists of exactly M letters without word breaks. So, there exist exactly N^M different Freish sentences.
But after recent election of Mr. Grass Jr. as Freeland president some words offending him were declared unprintable and all sentences containing at least one of them were forbidden. The sentence S contains a word W if W is a substring of S i.e. exists such k >= 1 that S[k] = W[1], S[k+1] = W[2], ...,S[k+len(W)-1] = W[len(W)], where k+len(W)-1 <= M and len(W) denotes length of W. Everyone who uses a forbidden sentence is to be put to jail for 10 years.
Find out how many different sentences can be used now by freelanders without risk to be put to jail for using it.
But after recent election of Mr. Grass Jr. as Freeland president some words offending him were declared unprintable and all sentences containing at least one of them were forbidden. The sentence S contains a word W if W is a substring of S i.e. exists such k >= 1 that S[k] = W[1], S[k+1] = W[2], ...,S[k+len(W)-1] = W[len(W)], where k+len(W)-1 <= M and len(W) denotes length of W. Everyone who uses a forbidden sentence is to be put to jail for 10 years.
Find out how many different sentences can be used now by freelanders without risk to be put to jail for using it.
Input
The first line of the input file contains three integer numbers: N -- the number of letters in Freish alphabet, M -- the length of all Freish sentences and P -- the number of forbidden words (1 <= N <= 50, 1 <= M <= 50, 0 <= P <= 10).
The second line contains exactly N different characters -- the letters of the Freish alphabet (all with ASCII code greater than 32).
The following P lines contain forbidden words, each not longer than min(M, 10) characters, all containing only letters of Freish alphabet.
The second line contains exactly N different characters -- the letters of the Freish alphabet (all with ASCII code greater than 32).
The following P lines contain forbidden words, each not longer than min(M, 10) characters, all containing only letters of Freish alphabet.
Output
Output the only integer number -- the number of different sentences freelanders can safely use.
Sample Input
2 3 1abbb
Sample Output
5
Source
Northeastern Europe 2001, Northern Subregion
- poj 1625 Censored!//AC自动机+DP+大数
- POJ 1625 Censored【AC自动机+DP+大数】
- 【AC自动机+DP+大数】 POJ 1625 Censored!
- poj 1625 Censored! 【AC自动机 + DP + 强力大数模版】
- poj--1625Censored!+AC自动机上的dp+大数
- POJ 1625 Censored! (AC自动机+DP+大数加法)
- POJ 1625-Censored!(AC自动机+DP+大数加法)
- POJ--1625[Censored!] AC自动机+DP+高精度
- POJ 1625 Censored!(AC自动机+DP)
- poj 1625 Censored!(AC自动机+DP+高精度)
- POJ 1625 Censored!(AC自动机,DP)
- poj 1625 Censored! (ac自动机+dp)
- poj 1625 Censored! AC自动机+dp+高精度
- [AC自动机+dp+高精度] poj 1625 Censored!
- POJ 1625 Censored(AC自动机+dp)
- POJ 1625 Censored! AC自动机+DP+高精度 *
- POJ 1625 Censored!(AC自动机+DP)
- HDU 1625 Censored! (AC自动机 + 大数 + dp)
- MySQL5.1 忘记root密码的解决方法
- 深入理解malloc函数(c语言)
- Swing中设置鼠标形状
- 看计算机书籍的一点想法
- 获取无窗口RichEdit的HostWindow的方法
- poj 1625 Censored!//AC自动机+DP+大数
- PDF简介
- JSTL学习笔记
- rowstatus作用
- 鸟哥的Linux私房菜
- ARM体系结构与编程学习(七)
- 腾讯实习生HR面
- Lucene的索引详解
- poj 1256