Recently has been in the optimization of the project string matching problem, so I think of the self-motive, before also read some articles, has not been implemented, now the project to use, and then saw some of the AC automata article, here to achieve a simple AC automata small interface, I am the realization of the automaton State structure using the trie tree, to achieve a simple, but to a certain extent
Blog:www.wjyyy.top
ac automata is a convenient multi-pattern string matching algorithm for cancer . Based on the dictionary tree, a similar kmp thinking is used.
ac automata unlike KMP, AC automata can match multiple pattern strings at the same time, and the complexity does not reach too high. If the string is matched multiple times with KMP, the complexity is
3172: [Tjoi2013] Word time
limit: ten Sec
Memory Limit: MB
Submit: 1890
Solved: 877
[Submit] [Status] [Discuss]
DescriptionSomeone reads a paper, a paper is made up of many words. But he found that a word would appear many times in the paper, and now wondered how many times each word appeared in the paper.InputThe first integer n, which represents how many words, and the next n rows of one word per line. Each word is made up of lowercase letters, nOutputoutputs n integ
POJ1625 --- Censored! (AC automation + dp + high precision) and ac Automation
DescriptionThe alphabet of Freeland consists of exactly N letters. each sentence of Freeland language (also known as Freish) consists of exactly M letters without word breaks. so, there exist exactly N ^ M different Freish sentences.
But after recent election of Mr. grass Jr. as Freeland president some words offending him were de
Virus attack continues
Problem's link: http://acm.hdu.edu.cn/showproblem.php? PID = 1, 3065
Mean:
Chinese question, not explained.
Analyze:
Application of AC automatic machines. This topic needs to store all the mode strings, and the value of base must be clarified. Because the mode strings are uppercase letters, we can use pruning to accelerate the process.
Time Complexity:O (n) + O (ML)
Source code:
// Memory time // 1347 K 0 Ms //: snarl_jsb /
Question link: http://acm.hdu.edu.cn/showproblem.php? PID = 1, 1219
Simple question.
Gains:
Use of gets. AC me
Time Limit: 2000/1000 MS (Java/others) memory limit: 65536/32768 K (Java/Others)Total submission (s): 5280 accepted submission (s): 2388 Problem descriptionignatius is doing his homework now. The teacher gives him some articles and asks him to tell how many times each letter appears.
It's really easy, isn' t it? So come on and
The root of the word ac
AC 97 is all called "Audio Codec 97", meaning "audio multimedia digital Signal codec". This is by Intel, analog devices and other related manufacturers to develop the audio circuit system standards, and has been widely recognized by the industry. AC 97 is a technical specification, in short, it employs a dual-chip architecture that allows
For DHCP services, settings can be made on many platforms. So here we will focus on the Linux DHCP server via option 43 implementation of the H3C AP automatically contact the relevant content of the AC registration. The original DHCP server was placed on the switch, but because of the recent preparation to change the network topology, so to migrate the DHCP server, the operating system is RHEL5.3,DHCP version 3.05Hit H3C 800 phone, second-line enginee
What is the function of the diode in AC DC power? Output voltage? The output current is determined by the maximum rated current of the diode. The 1n4007 diode (Universal Silicon Rectifier diode M7) is rated at 1 A and the output current is less than 1 a.
If you want to understand it, talk about it from the AC power.220 Volts AC Point has two lines, a 0 line, his
bzoj3881 [Coci2015]divljak
Original title address : http://www.lydsy.com/JudgeOnline/problem.php?id=3881
Test Instructions:Alice has n strings of s1,s2 ... Sn s 1, s 2 ... S n S_1,s_2...s_n,bob has a string set T, and the beginning of the collection is empty.Then there are the Q operations, which take two forms:"1 P", Bob adds a string P to his own collection."2 X", Alice asks Bob how many strings in the collection T contain the string Sx S x s_x. (We call string A contains string B, when and o
Spit Groove: The output of this problem is disgusting, disgusting, disgusting, disgusting, *10000 ...
Tle Method:
Violent KMP, put all the 100 101 111-like schemes, all and the original string match once ... Then sort the output.
compiling ... Compile:ok
Executing
... Test 1:test OK [0.008 secs, 9424 KB]
test 2:test OK [0.003 secs, 9424 KB]
test 3:test OK [0.032 secs, 9424 kb]
> Run 5:execution error:your Program ("contact") used more than the
allotted runtime
Title DescriptionAlice has n strings S_1,s_2...s_n,bob has a string set T, and the first collection is empty. The next thing that happens is the Q operation, which has two forms: "1 P", and Bob adds a string P to his own collection. "2 X", Alice asks Bob how many strings in a collection T contain string s_x. (We call string A contains string B, and if and only if B is a substring of a) Bob is in trouble and needs your help.InputLine 1th, a number n; next n lines, one string per line for s_i, nex
Implement function--input n,m, provide a dictionary of n words, and then in the last input of M string to match (about AC automata algorithm, here no longer repeat, see: Aho-corasick multi-mode matching algorithm, AC automata detailed . Given the fact that dictionaries are sometimes fairly sparse, the chi and bro pointers are introduced for optimization-the principle is similar to the adjacency table, which
, really, even today is April Fool's Day, but this is my truth .... Even if it's a big fruit, Mama egg! I've been a full a for 1 hours, one hours ... Everyone a friend, AC and not easy, and the line and cherish ah. According to the general idea of C + +, this problem is to use the format input scanf ("%d-%d-%d", Year,month,day), and then again with a leap year common year to engage in, and then consider no 18 birthday this case, is if (month==2 day==2
Recently need to use the text of the phonetic similarity calculation, looked at the HANKCS great God in the HANLP through the AC automata to achieve pinyin storage, want to turn it into a Python version. Start chewing on the AC automaton.
AC automata are established in Trie tree and KMP string matching algorithms. First chew the trie tree.
About the concept of tr
problem:
Give you n a string, n (1
Ask not to disturb the string order, take several strings from it, so that the previous string is the substring of the latter string, to satisfy the preceding conditions of the string is worth and maximum, to find this value.
Think:
Establish an AC automaton. The following check takes the maximum value with each string being the last string to fetch. Then, when checking the I-string, it is the value of the zero-nod
Question: Water problem ... is to find the number of times a-Z letter appears. Note There is a blank line between each test event.
Import Java.util.Scanner;
public class Main {public
static void Main (string[] args) {
Scanner sc = new Scanner (system.in);
Int[] Mat = new INT[26];
int temp = 0;
while (Sc.hasnext ()) {
String test = Sc.nextline ();
Initialized to 0 for
(int i = 0; i
C Language code:
#include
AC Me Ti
B-not AC this summer holiday
crawling in process ...
crawling failed
Time Limit:1000MS
Memory Limit:32768KB
64bit IO Format:%I64D %i64u Submitstatus
Description "This summer holiday is not AC. ”Yes ”"Then what are you doing?" ”"Watch the World Cup, idiot." ”"@#$%^*% ..."Indeed, the World Cup has come, the fans of the festival has come, it is estimated that many acmer will also throw away the computer, to
http://acdream.info/problem?pid=1019Problem DescriptionWe have a long long string, and we'll have the kinds of operation on it.C i y : Change the ith letter to y.Q i j : Check whether the substring from ith to jth letter is a palindrome.InputThere is multiple test cases.The first line contains a string whose length was not large than 1,000,000.The next line contains a integer N indicating the number of operations.The next N lines Each lines contains a operation.All letters in the input is lower-
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.