多多色-多人伦交性欧美在线观看-多人伦精品一区二区三区视频-多色视频-免费黄色视屏网站-免费黄色在线

國內(nèi)最全I(xiàn)T社區(qū)平臺(tái) 聯(lián)系我們 | 收藏本站
阿里云優(yōu)惠2
您當(dāng)前位置:首頁 > php開源 > php教程 > HDU 3695 Computer Virus on Planet Pandora (AC自動(dòng)機(jī))

HDU 3695 Computer Virus on Planet Pandora (AC自動(dòng)機(jī))

來源:程序員人生   發(fā)布時(shí)間:2015-03-19 08:34:21 閱讀次數(shù):3527次


Computer Virus on Planet Pandora

Time Limit: 6000/2000 MS (Java/Others)    Memory Limit: 256000/128000 K (Java/Others)

Total Submission(s): 2879    Accepted Submission(s): 808

Problem Description

    Aliens on planet Pandora also write computer programs like us. Their programs only consist of capital letters (‘A’ to ‘Z’) which they learned from the Earth. On
planet Pandora, hackers make computer virus, so they also have anti-virus software. Of course they learned virus scanning algorithm from the Earth. Every virus has a pattern string which consists of only capital letters. If a virus’s pattern string is a substring of a program, or the pattern string is a substring of the reverse of that program, they can say the program is infected by that virus. Give you a program and a list of virus pattern strings, please write a program to figure out how many viruses the program is infected by.
 

Input
There are multiple test cases. The first line in the input is an integer T ( T<= 10) indicating the number of test cases.

For each test case:

The first line is a integer n( 0 < n <= 250) indicating the number of virus pattern strings.

Then n lines follows, each represents a virus pattern string. Every pattern string stands for a virus. It’s guaranteed that those n pattern strings are all different so there
are n different viruses. The length of pattern string is no more than 1,000 and a pattern string at least consists of one letter.

The last line of a test case is the program. The program may be described in a compressed format. A compressed program consists of capital letters and
“compressors”. A “compressor” is in the following format:

[qx]

q is a number( 0 < q <= 5,000,000)and x is a capital letter. It means q consecutive letter xs in the original uncompressed program. For example, [6K] means
‘KKKKKK’ in the original program. So, if a compressed program is like:

AB[2D]E[7K]G

It actually is ABDDEKKKKKKKG after decompressed to original format.

The length of the program is at least 1 and at most 5,100,000, no matter in the compressed format or after it is decompressed to original format.
 

Output
For each test case, print an integer K in a line meaning that the program is infected by K viruses.
 

Sample Input
3 2 AB DCB DACB 3 ABC CDE GHI ABCCDEFIHG 4 ABB ACDEE BBB FEEE A[2B]CD[4E]F
 

Sample Output
0 3 2
Hint
In the second case in the sample input, the reverse of the program is ‘GHIFEDCCBA’, and ‘GHI’ is a substring of the reverse, so the program is infected by virus ‘GHI’.
 

Source
2010 Asia Fuzhou Regional Contest
 

題目鏈接:http://acm.hdu.edu.cn/showproblem.php?pid=3695

題目大意:求不同的單詞或其倒敘在文章中出現(xiàn)的次數(shù),文章可能以緊縮的情勢展現(xiàn),[qx]表示連續(xù)'x'個(gè)q

題目分析:由于要斟酌倒敘,能想到兩種方案,1個(gè)是用單詞和其倒敘構(gòu)建字典樹,由于這題數(shù)據(jù)量太大,這樣會(huì)MLE,只能采取第2種方法,將文章正序匹配1次再倒敘匹配1次,在這里我用了1句while(i < (int)strlen(get)) {...}由于這個(gè)T了1下午,改成int l = strlen(get);
while(i < l) {...}就好了,不明白為何

#include <cstdio> #include <cstring> #include <queue> #include <algorithm> using namespace std; int const MAX = 5100005; char s[1005], get[MAX], text[MAX]; struct node { node *next[26]; node *fail; bool end; node() { memset(next, NULL, sizeof(next)); fail = NULL; end = false; } }; void Insert(node *p, char *s) { for(int i = 0; s[i] != ' 主站蜘蛛池模板: 国产亚洲精品观看91在线 | 高清在线亚洲精品国产二区 | 国产专区在线视频 | 日本番囗 | 国产人伦视频在线观看 | 欧美一级欧美一级毛片 | 免费一看一级欧美 | 亚洲高清专区 | 亚洲国产成人久久三区 | 99爱视频99爱在线观看免费 | 免费观看的男女羞羞视频 | 亚洲欧美卡通成人制服动漫 | ck7788免费视频 | 九九99久久精品在免费线bt | 国产麻豆精品在线观看 | 波多野结衣视频在线免费观看 | 欧美国产一区二区二区 | 日日撸夜夜操 | 成人天堂在线 | 久久久久国产一级毛片高清版 | 欧美日韩国 | 欧洲美女高清一级毛片 | 一区二区亚洲精品 | 欧美亚洲另类在线 | 91久久在线| 亚洲自拍图片区 | 免费在线观看a | 亚洲有码区 | 手机在线日韩高清理论片 | 久久一区二区三区不卡 | 国产午夜精品不卡观看 | 欧美亚洲桃花综合 | 青青青青爽极品在线视频 | 免费在线观看视频a | freexxxhd性| 亚洲午夜精品久久久久久成年 | a一级爱做片免费 | 女人18一级特级毛片免费看 | 成a人v欧美综合天堂 | 一级做a爰全过程免费视频毛片 | 国产在线观看成人免费视频 |