This method of judging really didn't think ...For the match m in S, if the previous match position of M is the match position of the pre with this time now satisfies Now-pre >= m.length, then add 1.The judgment was too 233 .#include ZOJ 3228Searching the String ac automaton does not repeat the match
viruses. At this time he did not know where to start. So I would like to ask you to help. Small T is also a short-tempered oh, so the faster the better to solve the problem Oh ~ ~Input first line, an integer N (1Next n rows, each line represents a virus signature, and the signature string length is between 20-200.Each virus has a number, according to 1-n.Virus signatures of different numbers will not be the same.After this line, there is an integer M (1Next m line, each line represents a websit
characters (not including carriage returns).Output is one per line in the following format, outputting the number of occurrences per virus. No output is required for viruses that do not appear.Virus signature: Number of occurrencesA colon is followed by a space that is output in the order in which the virus signature is entered.Sample Input3aabbccooxxcc%daaaoen .... ENDSample OutputAa:2cc:1Hinthit: All cases not mentioned in the title description should be considered. For example, two virus sig
The dictionary tree of the cock silk ... Drunk ...#include#include#include#include#include#include#includeUsingNamespace Std;struct Trie{int Next[500010][26],fail[500010],isend[500010];int root, L;IntNewNode(){For(int I=0; I26; I++)This string of jumps empties next[L][i]=-1; Isend[L++]=0;Not a node layerReturn L-1;Returns the ordinal of this point}voidInit(){L=0; Root=NewNode();Give the root a point}voidInsert(Char buf[]){int Len=Strlen(buf);int now= root;For(int I=0; I; I++){If(Next[Now][buf[I]
(intI=1; i)Wuyi { thevis[pos]=true; - intt=str[i]-'a'+1; Wu while(!son[pos][t]) pos=Fail[pos]; -pos=Son[pos][t]; About if(!Vis[pos]) $ for(intj=pos;j;j=Fail[j]) - { -ans+=Word[j]; -word[j]=0; A } + } the returnAns; - } $ intMain () the { thescanf"%d",Kase); the for(intKase=1; kase) the { -scanf"%d",N); Init (); in for(intI=1; i) the { thescanf"%s", str+1); About Insert (str); the } the Mak
Contest 10The main topic: give you a series of n number, q times asked. Ask 1 to change a location to value B. Ask 2 then ask L-r what is the number of K-large between. Simply put, it is the dynamic interval K problem with the modification.Problem-solving idea: Maintain CI's position in the number of numbers in the series after the treap, and maintain CI's positional relationship in the sequence by using the line tree. In fact, I think this is the connotation. Then for the query interval l-r th
#include#include#includeUsingnamespace Std;Constint maxv=510;Constint inf=0X3FFFFFFF;int n,m,c1,c2;BOOL VIS[MAXV];int G[MAXV][MAXV];Distance between citiesint WEIGHT[MAXV];Number of rescuers in each cityint D[MAXV];Shortest distanceint W[MAXV];Can bring the most peopleint NUM[MAXV];Shortest Path Bar numbervoid Dijkstra (int s) {memset (num,0,sizeof (num)); memset (Vis,Falsesizeof (VIS)); Fill (D,d+maxv,inf); Memset (W,0,sizeof (w)); d[s]=0;The city distance to the city is 0 W[s]=weight[s];The nu
#include#includeUsingnamespace Std;Constint aim=6174;int n;int arr[4];BOOL Nonincreasingorder (int A,int b) {return a>b;}BOOL Nondecreasingorder (int A,int b) {return aint Tonum ()Get this number {int sum=0;Forint i=0; i4; ++i) {sum=sum*10+arr[i]; }return sum;}void Toarr () {Forint i=0; i4; ++i)Disassemble number {arr[i]=n%10; N/=10; }}int main () {scanf ("%d", n);int Min,max;//the minimum number of permutations, the maximum number of permutations while (1) {Toarr (); //disassembly sort (arr,arr
#include#includeUsingnamespace Std;int arr[100066];int FIND (int L,int R,int aim)Binary lookup, from L to R, find aim{int mid;while (l2;if (Arr[mid]==aim)return mid;Find: Return coordinatesElseif (Arr[mid]1;else r=mid-1; }Return-1;Not found}int main () {int n,m; scanf"%d%d", n,m);Forint i=0; I"%d", arr[i]); Sort (arr,arr+n);Sorting before you can find it with two pointsfor (int i=0; iint x=find (i+1,n-1,m-arr[i]); //find the opposite number labeled I number, L from the beginning of the i+1 can b
#include#includeint harsh[1066];int main () {memset (HARSH,0,sizeof (HARSH));int n,m; scanf"%d%d", n,m);Forint i=0; Iint tmp; scanf"%d", tmp); ++HARSH[TMP]; }Forint i=0; i1066; ++i) {if (harsh[i]==0" //this number does not continue; if (harsh[m-i]>0) {if (i==m-i HARSH [I]2) //these two numbers are the same time, but only one is available, also not continue ; printf ( "%d%d" I,m-i ); //has ruled out the possibility of output, the conditions are satisfied on the output return 0;} printf ( Span cl
#include#includeUsingnamespace Std;int arr1[1000066];int arr2[1000066];int main () {int n1,n2; scanf"%d", AMP;N1);Forint i=0; I"%d", arr1[i]);} scanf"%d", AMP;N2);Forint i=0; I"%d", arr2[i]);} arr1[n1]=0x7fffffff,arr2[n2]=0x7FFFFFFF"Caution" because when the output is the minimum number, it is possible to set the end of the last number of arrays is infiniteint middle= (n1+n2-1)/2;int i1=0,i2=0; //represents two arrays currently pointing, starting from 0 for (int I=0; I//find the first middle sma
#include#include#include#includeUsingnamespace Std;Constint max=1010;int n,m;n nodes, m non-leaf nodesLongLongint S;Right value to be measuredLongLongint Weight[max];The weight of each node vectorInt> Child[max];Storage nodeBOOL CMP (int A,int b) {return weight[a]>weight[b];}LongLongint sum=0;vectorInt> path;Save Path Weight valuevoid DFS (int root) {if (child[root].size () = =0) {if (sum==s) {printf ("%d", Path.front ());The weight s is not 0, and the condition must have a path. Single output f
#include#includeUsingnamespace Std;Constint max=100010;int depest=0,times=0;vectorInt> Child[max];child[father [Child] two-dimensional array representation tree structurevoid DFS (int root,int depth) {if (child[root].size () = =0)The leaf node begins to judge the depth {if (depth>depest) {depest=depth; times=1; }Elseif (depth==depest)The same as the deepest depth, the number of times plus 1 ++times;Return }Forint i=0; I1);}int main () {int root=-1,n;Double p,r; scanf"%d%lf%lf", n,p,r); R/=100;in
be grazing in I state - { $ if(!judge (i)) the { thest[k++]=i; the } the } - for(intI=0; i//Initialize the first line of State in { thedp[0][i]= (!judge (0, i)); the } About for(intI=1; i) the { the for(intj=0; j) the { + if(Judge (I,j))Continue;//Determine if line I can herd cows in J. - for(intL=0; l) the {Bayi
only the R pointer is moved back. If the current blue block length is larger than the current yellow brick length plus y, then move the L pointer.AC Code:1#include 2 intN,m,x,y,l=1, r=1;3 intylw[100010],ble[100010];4 Long Longans;5 intMain () {6scanf"%d%d%d%d",n,m,x,Y);7 for(intI=1; i"%d",ylw[i]);8 for(intI=1; i"%d",ble[i]);9 while(lN) {Ten if(ble[r]>ylw[n]+y| | ble[m]1]-x) Break;//Special Award of extreme situations One if(ble[r]>=ylw[l]-xble[r]Continue;} A
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.