Advertising:#include int main(){ puts("转载请注明出处[vmurder]谢谢"); puts("网址:blog.csdn.net/vmurder/article/details/44003109");}ExercisesThe process of establishing an AC automaton can be changed to KMP.Anyway single string 233.Code:#include #include #include #include #include #define Tusing namespace STD;intN,m,p;structmrx{intX[T][T];} Ini,std,trs,e; MRXoperator* (ConstMRX a,ConstMRX b) {MRX c=e;intI,j,k; for(i=0; i for(j=0; j for(k=0; kLong Long) a.x[
Title Effect:Given that DNA has a correct sequential value. Please construct a length I of DNA in this sequence to make the DNA in the correct order of magnitude great. It is considered to be a negative output crackling.。。IDEAS:The construction sequence is, AC has to go on the active machine, for the maximum use of DPDp[i][j][k] means that it is now constructed to the length I.At this point we put the current character on the J node. and satisfies the
Evil" website source code, the source string length within 2000000. Characters in the string are ASCII-visible characters (not including carriage returns).Outputoutput each virus occurrence in the following format, one per line. 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:1 Hint hit: All si
separated by a space, if a website contains a virus, the number of viruses will not exceed 3.The last line of output statistics, the following formatTotal: Number of sites with virusesThere is a space after the colon.Sample Input3aaabbbccc2aaabbbcccbbaaccSample OutputWeb 1:1 2 3total:1Sourcemulti-university Training Contest 10-host by NITTitle Link: http://acm.hdu.edu.cn/showproblem.php?pid=2896Problem analysis: Establish trie tree for virus, run the AC
unforgettable day, experience a word, not until the last moment must not give up! Last minute AC through!In a situation where two adjacent dates are within one months, my algorithm calculates errors.The way you think of yourself is often quite redundant and prone to error, or your own skill is not enough.When choosing an algorithm, you should choose simple and error-prone lines.It is not necessary to discuss the situation in a piece of discussion, bu
. The starting state is 0, and then a new state is generated for each valid Input. But before the state is generated, check to see if it already exists.(2) int fail[m];The fail array stores the steering state after the state obtains input, if the result is Fail.(3) string output[m];An output array is a string array that stores a string that is in the state as the final State. of course, the string is not unique, and one of the core tasks of the AC alg
++) $ { - if(Next[now][i] = =-1) -Next[now][i] =Next[fail[now]][i]; - Else A { +Fail[next[now][i]] =Next[fail[now]][i]; the Q.push (Next[now][i]); - } $ } the } the } the intnum[ +]; the voidQueryCharBuf[],intNintmm[]) - { in for(inti =1; I ) theNum[i] =0; the intLen = (int) strlen (BUF); About intnow =Root; the for(inti =0; i ) the { thenow =
think that this is a search problem and then start a brute force search, and the final tle becomes * *. Let's analyze the solution of this problem first, it wants you to divide the goods into two piles, and the value is equal so, we have an optimization when the total value of the item is%2==1, it is determined that it cannot be divided evenly if%2==0 we start DP This DP is a bare multi-backpack DP We push with the value of the current item Whether the value exists value for the item of I the
once, moreover the main string each character can use up to X times, asks how to match makes obtains the value biggest.Each pattern string can be found in the matching position of the main string by an AC automaton, which is equivalent to the interval.In fact, this problem is equivalent to the selection of the maximum right and the interval on a single axis, so that the number of each point is covered by no more than X. Interval k coverage problem, P
different.Outputfor each test cases,print the answer MOD 1000000007 on one line.Sample Input2RD 2RRDDDR3Sample Output110SourceField=problemkey=2013+acm%2ficpc+asia+regional+nanjing+onlinesource=1searchmode=source ">2013 ACM/ICPC Asia Regional Nanjing Onlinerecommendliuyiding | We have carefully selected several similar problems for you:5017 5016 5015pid=5014 "target=" _blank ">5014pid=5013 "target=" _blank ">5013Top-level model: AC own active machine
http://acm.hust.edu.cn/vjudge/problem/33057Test instructions: Find out how many times a two-dimensional template string p appears in a two-dimensional text string T.ExercisesSplit the template string p for each line, build an AC automaton.Splits each line of the text string T, matches p in the automaton, Ct[i][j] indicates how many rows correspond to P with a point (I,J) as the upper-left corner, and a large rectangle such as p.The i,j of the last ct[
consists of the Integersn Andm -the length of the string, written by Lucy and the number of words in the Dictionar Y. The second line of the test case consists of the string itself-n characters, either A question mark or a small Latin letter. then,m lines follow. Each line consist of a single string of small Latin letters-the word from the dictionary. OutputFor each test case, output a, lines. The first line should contain the maximal number of occurrences. The second line should contain
Topic Link: Click to open the linkThe main topic: Give n strings, and M pattern string, define F (A, B) is the number of strings in string A, and now for each a string is calculated∑f (AI,BJ) (1 An AC automaton is established for M-mode strings, then each main string is put into the automaton, and the number of strings in B is counted by the main string and output.Attention:tag, you may have more than one pattern string.When counting, use fail to go b
gene has highest W value. There is so many different genes with length l, and Dr. X is not good at programming, can-help him W value of the best rabbit.Inputthere is multiple test cases. The first line is a integers n (1≤n≤10), L (1≤l≤100), indicating the number of the particular gene Segment and the length of rabbits ' genes.The next n lines each line contains a string DNAi and an integer WI (|wi|≤100), indicating this gene segment and the Val UE it can contribute to a rabbit ' s W.Outputfor e
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.