underline text generator

Read about underline text generator, The latest news, videos, and discussion topics about underline text generator from alibabacloud.com

BZOJ1030 [JSOI2007] Text generator

]; 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[

BZOJ1030: [JSOI2007] Text generator

++) { intson=T[x].c[i]; if(son==-1)Continue; if(x==0) t[son].fail=0; Else { intj=T[x].fail; while(j!=0t[j].c[i]==-1) j=T[j].fail; T[son].fail=max (0, T[j].c[i]); if(t[t[son].fail].s==1) t[son].s=1; } list[++tail]=Son; } head++; }}intf[ the][11000];intMain () {intn,m; scanf ("%d%d",n,m); Tot=0; Clean (0); for(intI=1; i) {scanf ("%s", st+1); BT (); } BFS (); Memset (F,0,sizeof(f)); intsum=1; for(intI=1; i -)%Mod; f[0][0]=1; for(intu=1; u) {

"bzoj1030": [JSOI2007] Text generator string-ac automaton-DP

=0;i -; i++)if(PN) Pnf=p,q[++r]=pn,pn->th=R; + while(lR) { -p=q[++l]; the for(intI=0;i -; i++){ * if(PN) { $Q[++r]=pn,pn->th=R;Panax Notoginseng for(Pnf=p->fail; pnf!=root !pnf->next[i]; pnf=pnf->fail); - if(Pnf->next[i]) pnf=pnf->Next[i]; thePn->w|=pnf->W; + } A } the } + } - $ intQ_pow (intXinty) { $ intans=1; - for(; y; x=x*x%p, y=y>>1)if(y1) ans=ans*x%P; - returnans; the } - voiddp () {Wuyif[0][0

"Bzoj 1030" "Jsoi 2007" text generator ac automata + recursive

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"

Bzoj 1030 Text Generator

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

Bzoj 1030 [JSOI2007] text generator (AC automaton)

"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

bzoj1030: [JSOI2007] Text generator (AC automaton +DP)

];inlinevoidReadintk) { intf=1; k=0;CharC=GetChar (); while(c'0'|| C>'9') c=='-' (f=-1), c=GetChar (); while(c'9' c>='0') k=k*Ten+c-'0', c=GetChar (); K*=F; } InlinevoidInsert () {intLen=strlen (s+1), now=0; for(intI=1, ch;i) { if(!tree[now].nxt[ch=s[i]-'A']) Tree[now].nxt[ch]=++Tott; now=Tree[now].nxt[ch]; } Cnt[now]=1;} InlinevoidGetfail () {intFront=1, rear=0; tree[0].fail=-1; for(intI=0, too;i -; i++) if((too=tree[0].nxt[i]) h[++rear]=too; while(frontrear) { intn

Total Pages: 4 1 2 3 4 Go to: Go

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.