What is the right way to get started with ACM?

Author: Math lover
Link: https://www.zhihu.com/question/51727516/answer/127265733
Source: Zhihu The
copyright belongs to the author. For commercial reprints, please contact the author for authorization, and for non-commercial reprints, please indicate the source.

General entry order:
0. Basic grammar of C language (or open C++ directly, as a java player may be more popular, and it is easy to find a job in the future, but it is a bit difficult), [Reference books: Liu Rujia's "Algorithm" Competition entry classic", C++ entry can consider "c++ primer plus", java players can consider "think in java" or the Chinese version of "java programming ideas", please stay away from Tan Haoqiang...]
You can choose to cut some special questions to consolidate and Get used to the common input and output formats in ACM... For example, Hangdian's famous 100-question Problem Set
1. Some basic algorithms and data structures (queue stack tree graph and check stack DFS BFS shortest path minimum spanning tree topology sorting dynamic programming greedy search KMP Hash Trie AC Automata Fast Power Inverse Element Fermat's Little Theorem Euler Function Prime Number Sieve Decomposition Prime Factor) You can find two small partners to divide the labor and cooperate, and each claim the topic [Reference Book: Liu Rujia "Introduction to Algorithm Competition Classic Second" Edition" or "Algorithm Competition Training Manual", "Introduction to Algorithms"] At this time, there are many questions that can be written, you can choose some topics to make breakthroughs, and learn skills such as
[kuangbin takes you to fly] topic - simple search
[kuangbin belt You fly] Topic 4 Shortest path practice
[kuangbin takes you to fly] Topic 5 and collection
[kuangbin takes you to fly] Topic 6 Minimum spanning tree
[kuangbin takes you to fly] Topic 12 Basic DP1
[kuangbin takes you to fly] Topic 14 Fundamentals of Number Theory
[kuangbin takes you to fly] Topic 16 KMP & Extended KMP & Manacher
[kuangbin takes you to fly] Topic 17 AC Automata
If you and your friends are familiar with these and can write them out as soon as possible, then if there is no accident, you can get tickets for the live game in the online game (of course, you have to see the style of the questioner...)
2 . Some advanced algorithms and complex data structures (tree array, line segment tree, balanced tree, suffix array, bipartite graph, matching network flow, cost flow, cut point, bridge, strong connection, dual connection, recent common ancestor, four major DPs (digital dp interval, dp shape, pressure dp) Probability dp) Game Theory SG function)
[References: various blogs...]
[kuangbin takes you to fly] topic seven line segment tree
[kuangbin takes you to fly] topic nine connected graph
[kuangbin takes you to fly] topic ten Matching problem
[kuangbin takes you to fly] Topic eleven network flow
[kuangbin takes you to fly] Topic fifteen digital DP
[kuangbin takes you to fly] Topic eighteen suffix array
[kuangbin takes you to fly] Topic twenty-one probability & expectation
[kuangbin Take you to fly] After mastering these 22-interval DP
, it should be no problem to get the brand in the live game, and if you play well, you can get the silver medal. . . However, if you encounter a more brutal competition area...
2.5 At this time, if you start to form a team, you can go to some sets of questions, such as Contests - Virtual Judge
. Every game here is a video of what happened in the past, you can clone Then practice with your teammates.

3. Deeper tricks, more complex data structures (tree chaining, dynamic trees, persistent segment trees, DLX, suffix automata, palindromes, slope optimization/monotone queue optimization/quadragon optimization DP, plug dp , Mobius inversion...)
This part can best reflect the differences between people... IQ crushing is generally in this part. In order to get a gold medal, generally speaking, these knowledge must be mastered as much as possible.
[References: various papers, problem-solving reports]
The topics in this part are quite complicated, so please go to vjudge to find them....

3.5 is the same as 2.5, and if the domestic competitions in China are not enough for you, you can go to or - Codeforces to find the problems of regional competitions around the world, but the problem is solved. Not much guaranteed...

You may feel that the cost-effectiveness is very low. It is "possible" to get a brand after learning so many things, but what you gain is not necessarily a material brand, but also the bittersweet experience of the learning process (such as various WA TLE RE An AC after MLE), as well as sharing weal and woe with basic friends, and also exercised my learning ability (make good use of Baidu, Google, Wikipedia).
So
Good Luck and Have Fun.
==============I am the dividing line between WA and AC================

If you disagree with one word, you will get over a hundred likes. I am so happy~ I
will add:
These algorithms are easy to say, but difficult to use flexibly, and then they can be written within a certain period of time, and successfully passed the data test to get AC Harder.
As the templates in your hands are getting stronger and stronger, there are generally no naked template questions in regional competitions. Once they appear, they will definitely be scolded by everyone to go home. Therefore, in the process of comprehensive training, try to choose topics that require brainstorming, and don't blindly pursue topics that are particularly cool to paste a template on and leave the AC.
Generally, the types of questions that require brains: greedy, dynamic programming (preferably with optimization), combinatorics (pushing combinatorial formulas, various equivalent transformations), graph theory (network flow, shortest paths, matching) A mapping process. . .
Although it is said that young people need less water and more questions to enter Finals - kuangbin,
but it is not a good thing to play alone all the time behind closed doors. It is still necessary to exchange experiences with everyone, so as to avoid falling into a bottleneck.
 
Author: Wang Haohao
Link : https://www.zhihu.com/question/51727516/answer/153850404
Source: Zhihu The
copyright belongs to the author. For commercial reprints, please contact the author for authorization, and for non-commercial reprints, please indicate the source.

Students who have just learned ACM often have a lot of confusion and do not know where to start. In this article, I hope to share my little experience with you, hoping to be helpful to you.




1. Language is the most important basic skill


No matter what aspect you focus on, as long as it is a competition that is ultimately realized through a computer program, language is the first level that everyone has to pass. The languages ​​supported in the Asian competition include C/C++ and JAVA. First of all, let’s talk about JAVA. As we all know, as an object-oriented ace language, JAVA has its own unique advantages in the organization and security of large-scale projects, but for the specific occasions of informatics competitions, JAVA is not so suitable. Compared with C++, stream operations are much more complicated, and more importantly, the running speed of JAVA programs is more than 10 times slower than that of C++, and the running time limit of JAVA programs in competitions is often not relaxed in the same proportion, which is undoubtedly It puts forward higher requirements for algorithm design, which is quite unfavorable. In fact, I do not advocate that people use object-oriented programming thinking too much in this situation, because for small programs, it will not only take more time to write code, but also reduce the execution efficiency of the program.


Then talk about C and C++. Many students who are participating in the lecture are still in their freshman year. They have just finished learning the basic knowledge of C and have not been exposed to C++. In fact, there are still many players who use pure C on the field. They mainly value the efficiency of pure C. Therefore, if these students have limited time, they do not need to rush to learn a new language. As long as they improve their attainment in algorithm design, pure C can also exert great power.


Compared with C, the encapsulation of input and output streams in C++ greatly facilitates our operations, reduces the possibility of errors, and can well realize the switching between standard streams and file streams, which facilitates debugging. If some students are more concerned about this, they can try to mix C and C++. After all, it doesn't take much time to just learn the stream operations of C++.


Another support for C++ comes from the Standard Template Library (STL). The unified interface operations for basic data structures and the implementation of basic algorithms provided in the library can reduce the length of our code, which can save some time. However, in contrast, using STL requires some sacrifices in efficiency. For problems with a large input scale, sometimes STL must be abandoned, which means that we cannot exist "with STL, you can ignore the basic algorithm." In addition, the skilled and proper use of STL must be accumulated over a certain period of time, and the time complexity of various operations must be accurately understood, and the unfamiliar part of STL should not be abused, because it contains many beginners. Trap found.




Now we turn to the second aspect of the discussion, the accumulation of basic subject knowledge.




2. Basic knowledge based on mathematics is very important


Although it is defined as a programming competition, the problems encountered by the contestants are more that they do not have ideas to solve the problem, rather than having ideas but not being able to realize it. This is because the basic knowledge accumulated in ordinary times is not enough. The basic subjects involved in the competition mainly focus on mathematics, and there may also be some applications for physics, circuits, etc., but not many. Therefore, freshman students do not have to feel that they have not yet learned data structure and do not know where to start to improve, just pick up mathematics!


Let me talk about the main branches of mathematics applied in competitions:


1. Discrete mathematics - as the foundation of computer science , discrete book ordering is the most involved branch of mathematics in the competition, and the most important thing is graph theory and combinatorial mathematics, especially graph theory.


The reason why graph theory is used the most is that it has the most changes, and it can easily combine basic data structures and the basic ideas of many algorithms. The more used knowledge includes connectivity judgment, DFS and BFS, joint points and critical paths, Euler Circuits, Minimum Spanning Trees, Shortest Paths, Bipartite Graph Matching, and Network Flows, to name a few. Although the proportion of this part is very large, it is often the problem in the competition. If there are beginners who feel powerless for some specific content of this part, they don't have to worry, they can accumulate slowly.


Most of the combinatorial counting problems designed in the competition need to be solved by combinatorial mathematics. The knowledge in combinatorial mathematics is simpler than that of graph theory. Many knowledge are already familiar to students who have gone to the Olympic School in elementary school, but there are also some parts that need to be You can start learning with a preliminary understanding of group theory in algebraic structures. Combinatorics rarely appears in the form of difficult problems in competitions, but if the accumulation is not enough, any problem in this area may become a difficult problem.


2. Number Theory - The problems constructed by the model of prime number judgment and congruence often require more knowledge of number theory to solve. This part does not account for a large proportion in the competition, but as long as one comes, it is enough to make people with insufficient knowledge. People meditate for a while. Prime number judgment and congruence are most common in topics with a background in cryptography. After using common sense in cryptography to determine the general process, the core algorithm often involves the content of number theory.


3. Computational geometry - Computational geometry is relatively independent compared to other parts, which means that it is rarely combined with other knowledge points. The more commonly used parts include - line segment intersection judgment, polygons Area calculation, judgment of inner and outer points, convex hull, etc. Computational geometry questions won't be very difficult, but they'll never be the weakest.


4. Linear algebra - The application of linear algebra is all about matrices, and some problems that are ostensibly simulated can often use matrices to find better algorithms.


5. Probability Theory - The competition is based on a black box, which means that you can hardly use the idea of ​​using probability algorithms, but this does not mean that probability is useless. This can only be realized through a certain amount of practice.


6. Elementary mathematics and analytic geometry - this is mainly the knowledge of middle school. It is not used much, but at least it is more than advanced mathematics. I think you should be familiar with the relevant content in the mathematics manual, at least know where you can find it, or necessary.


7. Advanced mathematics - I have only encountered one topic that is solved purely by advanced mathematics, but the narrative background of some topics often needs to have a certain connection with this part, and there is no harm in grasping it firmly.


The above is the mathematical field involved in the competition, and it can be said that the scope is quite broad.




3. Data structures and algorithms are the real core


Let's talk about data structures first. It is necessary to master the basic expressions and operations of queues, stacks and graphs. As for trees, I personally think that there are but not many problems that need to be established. (But trees are often very important analysis tools) In addition, sorting and searching do not need to be proficient in all ways, but you must ensure that you have a time complexity for each situation. Minimum required solution. When it comes to time complexity, it’s time to talk about the hash table. The time limit during competition is far more than the space limit. This requires everyone to master the principle strategy of “exchanging space for time” as soon as possible. The data stored in the table must not be searched again at that time. If it is really impossible to build a hash table, see if you can build a binary search tree, etc. These are all strategies to gain time. Mastering these skills requires everyone to have a good understanding of the data. The structure, especially the algorithm complexity, has a more comprehensive rational and perceptual understanding.


Then talk about the algorithm. The most basic and commonly used algorithm is search, mainly the use of backtracking and branch-and-bound methods. What I want to say here is that some beginners do not pay much attention to pruning when learning these basic search algorithms, which is very undesirable, because all the search topics will not give you a large scale of test cases, you often There is no discernible problem with the running time of the program, but the real test data must be able to filter out those algorithms that are not pruned. In fact, the contestants basically use common search algorithms, and the discrimination of the topics is often based on optimizations such as pruning.


Another class of commonly used algorithms is centered on "similar or identical subproblems", including recursion, recursion, greedy methods, and dynamic programming. Among them, the most difficult to master is dynamic programming. How to abstract repeated sub-problems is the difficulty of many topics. The author recommends beginners to carefully understand some basic algorithms based on dynamic programming in graph theory (such as Floyd- Warshall's algorithm), and read more proofs of theorems, although this can't be of any direct help, but long-term persistence will be very helpful to thinking.




4. Practice, practice, practice


The accumulation of knowledge is important, but informatics is not seen, but practiced. This is the deepest experience of many predecessors. Only through the analysis and practice of specific topics can we truly master the use of mathematics and the application of algorithms. , and increase programming experience and skills in continuous practice, improve perceptual understanding of time complexity, optimize time allocation, and strengthen team cooperation. In short, it is absolutely impossible to just talk about soldiers here, and you must train yourself through actual combat.


Everyone must ask, where do we go to find problems to do, and how do we check whether the program is correct? There is no need to worry about this. There are already many online question-making sites. These sites provide a large number of question banks and support online scoring. You only need to submit the source code of the program, and you can immediately know whether your program is correct and running. Time used and memory consumed, etc. Here are a few sites I recommend to you (mostly from the top universities in the world ):

1. Ural: Ural is the abbreviation of Ural State University in Russia for Chinese students, where a Ural Online Problem Set is established and supports Online Judge. Many of Ural's topics are very algorithmic and anecdotal, and have been loved by the majority of domestic students.


2. UVA: UVA stands for the University of Valladolid in Spain. The university has a PROBLEM SET ARCHIVE with ONLINE JUDGE set up there, and supports ONLINE JUDGE in a similar form to the Ural University question bank. However, unlike Ural, UVA has more and more complex questions, and the test data of some questions are tricky. This makes the friends who just came to do the questions often feel at a loss, either it is difficult to find a suitable question, or after many times of Wrong Answers, they still do not know where they are wrong. If the main purpose of doing Ural questions is to train algorithms, then UVA questions can train a full range of basic skills and some necessary programming qualities.


3. ZOJ: ZOJ is an ONLINE JUDGE established by Zhejiang University. It is the first site of its kind established by a Chinese university, and it is also the best and most popular one. I practice here with many of my classmates. Although ZOJ is also positioned as an English website, there are more Chinese students here, so it makes people feel very friendly. There are currently more than 500 questions here, with moderate distribution of difficulty and difficulty, covering the types of questions on all continents and equipped with indexes. In addition, ZOJ's JUDGE system is one of several websites that performs well and rarely appears. Wrong Answer and Presentation error are confused. There is also an online competition every month, as long as registered users can participate.


4. ACM website of Peking University




above

 https://www.zhihu.com/question/51727516/answer/127265733
 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326024924&siteId=291194637