AC Automatic Machine

Source: Internet
Author: User

with the foundation of KMP and Trie, you can learn the Magic AC automata. AC automata is actually in the trie tree implementation of KMP, you can complete the multi-mode string matching.

AC automata is actually the creation of a state of the transfer diagram, the idea is very important.

Recommended Learning Links:

http://acm.uestc.edu.cn/bbs/read.php?tid=4294

http://blog.csdn.net/niushuai666/article/details/7002823

http://hi.baidu.com/nialv7/item/ce1ce015d44a6ba7feded52d

AC Automata Special training Links:Http://acm.hust.edu.cn/vjudge/contest/view.action?cid=25605#overview Here I submit the code is public and can see

title Source: http://www.notonlysuccess.com/index.php/aho-corasick-automaton/

Writing the AC automata code style is Shang theological, good concise, write up a great feeling.

1, HDU 2222 Keywords The basic entry question of the Search

is to find several pattern strings in the target string.

Very basic. Use an int type of end array record to query once.

View Code

2, HDU 2896 virus attack

This is similar to the above question, to output the ID of the pattern string, with the end to record the ID on it. And the branches of the trie tree are 128.

Here

View Code

3, HDU 3065 virus attacks continue

This problem is not a small change, it is necessary to output the number of occurrences of each pattern string, query time using an array to record it can be

View Code

4, ZOJ 3430 Detect the Virus

Mainly decoding process, after decoding is the template problem.

The number of types of pattern strings that appear

Branch requires 256

View Code

5. POJ 2778 DNA Sequence

AC Automata + matrix acceleration

The idea of a state transfer diagram of an AC automaton at this time is very thorough.

AC automata is the ability to determine the state of the transfer.

View Code

6, HDU 2243 Postgraduate Examination Road boundless--word complex

This question is somewhat similar to the above question. But it needs to be summed.

So add one dimension to the matrix so that it can be perfectly solved

Here

View Code

7, POJ 1625 censored!

AC automata +dp+ High Accuracy

Good question

Here

View Code

8, HDU 2825 Wireless Password

AC automata + state compression DP

is equivalent to generating a state transfer on an AC automaton, and then a DP

View Code

9. HDU 2296 Ring

The solution that requires minimal output dictionary order

It's OK to add a character array to the DP.

View Code

10. HDU 2457 DNA Repair

It's a simple AC automaton, +DP.

View Code

11. ZOJ 3228 Searching the String

This question needs to query two kinds, one is can overlap, one is not overlapping.

The number of occurrences of the pattern string in the target string.

Add an array to record the last occurrence of the position, and then you can find the non-overlapping

View Code

12, HDU 3341 Lost ' s revenge

This problem is mainly the representation of the State, that is, record the number of occurrences of ACGT.

Then the number of times this ACGT is expressed, the State is to be transformed.

Here

View Code

13,HDU 3247 Resource archiver

Use the shortest path to preprocess the transition out of state. This can optimize many

View Code

14. ZOJ 3494 BCD Code

This problem is very God, digital DP and AC automata combined, too powerful.

Here

View Code

Let's start with a brief summary! Sorry, the time reason, write very simple, later have the opportunity to complement completely!

AC Automatic Machine

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.