POJ 2774 Long long Message suffix array////title:////the longest common substring of two strings.////:////suffix array. Concatenate two strings with one other character that does not appear in two strings, and at the end// Also use one character as the end. A string of substrings, which must be a prefix of a suffix. Find the common prefix LCP for the height array
Idea: This question is the same as wikioi 1306. It is also the number of different substrings. However, wikioi takes a long time and then uses the trie tree. But when I used that code to submit this question, I became dizzy ...... Because there are multiple groups of examples for this question, it takes a little longer.
So of course this question is made with an array of suffixes!
Algorithm analysis:
Each substring must be the prefix of a suffix. The
If it is a simple addition or subtraction operation expression, it is very simple to process the expression's first character in sequence.
However, for the four arithmetic operations, there are parentheses and multiplication and division first, and then addition and subtraction make the expression processing more responsible.
In 1950s, Jan Lukasiewicz, a Polish logologist, invented a suffix expression that does not require parentheses.
For example
cha
ArticleDirectory
Step 1: Create the customhandler. CS file. The Code is as follows:
Step 2 compile this file
Step.3 copy the compiled mmhandler. DLL to the bin directory of the site.
Step 4 register the handler in Web. config.
Step 1 open vs2005, "add new project", and "general processing program ". After a new file is created, vs automatically adds the following code to the file:
Step 2 rewrite the Code as follows:
Step 3: Create an imagecode. ASPX page and write the
I. Optional instruction suffixes
"S" Suffix: The instruction uses the "S" suffix. After the instruction is executed, the condition flag of the Status Register will be refreshed. If the "S" suffix is not used, the condition flag of the Status Register does not change after the command is executed. This flag is often used to test conditions, for example, whether to
Disubstr-distinct substringsNo TagsGiven A string, we need to find the total number of its distinct substrings.InputT-number of test cases. tEach test case consists of one string, whose length is OutputFor all test case output one number saying the number of distinct substrings.ExampleSample Input:2CccccAbabaSample Output:59Explanation for the TestCase with string Ababa:Len=1:a,bLen=2:ab,baLen=3:aba,babLen=4:abab,babaLen=5:ababaThus, total number of distinct substrings is 9.Submit solution!Title
3230: Similar substring
Time limit:20 Sec Memory limit:128 MB
DescriptionInputEnter line 1th, which contains 3 integer n,q. Q represents the number of inquiry groups.Line 2nd is the string s.Next Q line, two integers i and j per line. (1≤I≤J).OutputOutput a total of Q lines, a number per line represents the answer for each group of queries. If there is no string I or J substring, then output-1.Sample Input5 3Ababa3 55 98 10Sample Output1816-1HINTSample explanationThe 1th group asks: Two
The motherboard in the Assembly computer is the most important, but the user is not familiar with the motherboard model name, often ignore the motherboard suffix, such as the current mainstream ASUS B75 Motherboard, there is a suffix with M and V, Asus B75-M is much cheaper than Asus B75-V, if the merchant to recommend the motherboard, do not mention the suffix n
6 Topic Links: Click to open the link
(This is the problem of personal AC for the training questions of the suffix array, and the problems of informal teaching are for reference only.) )
(the suffix array has a specific solution in the introductory Classic training guide for algorithmic contests, and this part of the code is fully based on the code in this book as a template)
Understanding:
A, find the leng
First, the suffix expression introduction
The suffix expression is characterized by the computer operation is very convenient, need to use the stack, the computer processing process only need to read sequentially, if the number is encountered, then put in the stack, if the operator, then the two stack of numbers out of the operation;
For example, 1+2 suffix ex
Summary: This article discusses the time complexity of Related Algorithms for longest common substrings. Then, based on the suffix array, a time complexity O (N ^ 2 * logn) is proposed ), the space complexity is O (n. Although this algorithm is less complex than dynamic planning and suffix tree algorithm, it has the advantage of simple coding and easy-to-understand code, and is suitable for fast implement
; Int.
The basic algorithm for building trie is also very simple. It is nothing more than inserting each letter of each word into trie one by one. Check whether the prefix exists before insertion. If yes, it will be shared. Otherwise, the corresponding node and edge will be created. For example, to insert the word "add", you can perform the following steps:
Test the prefix "a" and find that edge a already exists. So we walked along side A to node.
Test the prefix "D" of the remaining s
Suffix automatic machine (SAM)
[3] is a more rigorous definition description and provides proof. However, this proves that I did not understand it. The following documents give some individuals an intuitive but rigorous understanding.
A suffix automatic machine with a given string a is a finite state automation (DFA). It can and can only accept the suffix of A, a
Title Description Description Tian Kai is a freshman at MIT. Prof. Handsomeg gave him a string of n-length lowercase letters that asked him to sort the n suffixes (suffix) of the string from small to large.What is a suffix? Suppose the string is s=s1s2 ... Sn, define Ti=sisi+1 ... Sn. T1, T2, ..., TN is called the N suffix of s.A comparison of string sizes is def
Suffix array DA (multiplication) algorithm for sa[n] and Rank[n] (Time O (nlogn), Space O (N))Sa[i]: Indicates the suffix starting subscript in the first positionRank[i]: Indicates the suffix suffix (i) ranked in the firstHeight[i]: LCP value representing sa[i-1] and Sa[i]H[i]: Represents
How does thinkphp fail to get the file suffix when deleting a file? When you delete a file, the system prompts that the file failed to be deleted. at last, var_bump saw that the file did not contain a suffix. Address: http: // localhost/2015/thinkphp/blog/User/Database/index/Action/del/file/D20160105T144608-1. SQL is this, I use var_dump ($ _ GET) printed:
array(2) { ["Action"]=> string(3) "del" ["file
C # Get the image suffix,
This is also a very simple function, so it is not necessary to open a blog. For a photo that knows the full path, if its path contains a suffix, you only need a line of code to get the Suffix:
1
varext = System.IO.Path.GetExtension("C:\\soar.jpg");
However, what if the file name does not contain a
This problem can be done with the suffix array, KMP methodSuffix array practice began to think of the solution, the method is to enumerate the string length len of the approximate K, see LCP (suffix (0), suffix (k)) length is n-k, if True len/k is the result.If the length of the LCP (suffix (0),
This article mainly introduces the method of PHP to modify the specified file suffix, the function foreachdir can realize the file directory detection, reading, opening and file suffix replacement functions, is very practical skills, the need for friends can refer to the next
Due to project requirements, the ASP suffix needs to be modified to PHP, because lazy t
Php obtains the summary of the file name suffix instance. When uploading php files, we need to obtain the file name suffix and then determine the simple file type. in php, the file name suffix acquisition method is very simple and there are many ways, next I will summarize how to determine the type of a simple file after obtaining the
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.