]; A Inc (h); the forI: =1 to - Do begin +Y: =tr[x, I]; - ifY >0 Then begin $ Inc (T); $Q[t]: =y; -X1: =Fai[x]; - whileTrue Do begin the ifTR[X1, I] >0 Then begin -Fai[y]: =tr[x1, I];Wuyi ifTAIL[TR[X1, I]] ThenTail[tr[x, I]]: =true; the Break - End; WuX1: =fai[x1]; - End; About End; $ End; - End; - End; - A procedureDP (t:longint); + var the I, J, X:longint; - $ begin the forI: =1 toTot Do begin the ifTail[
Always do not understand how to do ah, think for a long time $twt$Finally understand why find the first $fail$ to meet the criteria to calculate, because avoid repetition, this answer,,,Then $root$ below to connect to 26 nodes, here 26 letters are not in the dictionary is replaced with $f[i][0]$, this also thought for a long time, $==$ I still go Home farm.#include Finally made it out, because looking at someone else's template, which also,,,"Bzoj 1030" "Jsoi 2007"
Very old topic, a long time ago to learn AC automata when the A onceIt's a review today.We can turn the problem into a string that does not appear in a given string.We set up AC automata, set DP[I][J] to show that I have walked the current on the J-nodeThe word node is not transferred during DP#include Bzoj 1030 Text Generator
"Topic link" http://www.lydsy.com/JudgeOnline/problem.php?id=1030"The main topic"Find the number of strings that contain any given stringExercisesWe find the quantity that does not contain any given string, and use the complete set to reduce it,For a given string set up AC automata, with 1 nodes as the root, 0 nodes to 1 even full character set transfer as a super-source,So 0->match can match all strings that don't contain a given string,DP[I][J] Indicates the number of strings matched to the I
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.