Start your ACM-ICPC tour)

Source: Internet
Author: User

 

I think this article should have been written by someone, but it does not seem to exist in Google (maybe in English)
Baidu gave one, but it is not very decent.
Http://baike.baidu.com/view/94274.htm
Let me write one. This is also one thing That momodi commissioned to me at the beginning of last semester.

This article is intended for shoes who do not have much foundation or have the same knowledge of C language or data structures.

--

First, what is ACM/ICPC? ACM/ICPC (ACM International Collegiate Programming Contest, International College Students' Program Design Competition) is an authoritative organization of ACM (Association for Computing Machinery), which has a long history in the International Computer Industry) sponsored by the program design competition of the world's largest and most advanced college students.
-- This definition comes from Baidu encyclopedia-> ACM/ICPC. In fact, it is simply a few words: Thinking about algorithms, writing programs, and solving problems.

Although you need to first think about algorithms (an effective way to solve the problem), if you don't write a program, the algorithms you come up with will usually be confused: because your brain is not electric, instead of using a computer to think about how to solve the problem, it usually cannot be effectively converted into a computer language source program (of course, it doesn't mean that you have learned to write a program and your mind is electric ). The process of writing a program is actually to use the human brain as a computer to talk to the computer, so that it can understand what it wants to do. In conclusion, it is necessary to learn computer languages first so that you can deal with computers and solve the problems you want to solve.

ACM/ICPC supports three computer languages: C, C ++, and Java. Support for Pascal has been canceled, but most online evaluation systems still support Pascal. If you have never learned a computer language, you need to pick one of them. So if you have learned one of them, you can start immediately. However, we recommend that you learn C ++ either. C ++ is an apprentice of C language. It not only learns the flexibility of C language, but also creates a lot of new skills to facilitate programmers, such as object-oriented mechanisms and STL (standard template library. In addition, Java is also worth learning, because its c ++ apprentice is a bit dumb, but it is a completely object-oriented language, and there are still some less self-developed efforts in C ++, for example, bigint (high-precision Integer class), if it is implemented using C ++, you need to write hundreds of lines of code (if the question is open, you can cry), but in Java, you can use it after a simple import.

Learning computer language is actually very simple-just a few words written and written, bubble mm still does not know how many rhetoric to learn, so we should use the computer as a bubble, um. This is a process that changes the way you think about the problem, and even has a great impact on your way of doing things. The following uses C/C ++ as an example.

It is very necessary to find a good book (because cram schools are very expensive ). Although C ++ is recommended above, you may wish to start with C, because C has the least effort, the fastest way to get started (there are always a lot of confusing and incredible words in the C ++ secret), but concentration is the essence. It is not easy to learn [excellent] C skills. Here we recommend Tsinghua University Press.
Mr. Tan haoqiang's "C program design" (the third edition already exists ). With a good book, you can start.

Then we can find a comfortable software for writing code for ourselves. We usually call it ide, integrated development environment, and integrated development environment. Of course, beginners will find an IDE that is easy to get started quickly. We recommend devcpp, lightweight and free (free of charge !) Easy to use, of course, Microsoft's visual
Studio is also very good, its debugging function is very powerful, the design is also more humane, but the old vc6 is not enough to meet the C/C ++ standard (vc2005 or above OK) -- It is also a little expensive (by the way, the M $ dreamspark program allows students to use genuine Visual Studio 2008 for free, for details, Baidu ). If you have the confidence to challenge yourself, the best solution is undoubtedly the [Vim/Emacs] + [gcc/g ++] with the most Nb. Vim and Emacs are both powerful editors. They can be used with the same open-source free gcc/g ++ compiler, which can significantly increase the speed of your coding (there is a saying that, there are three types of programmers in the world: Emacs, Vim, and other editors ). Then you can open the teaching material, read the history of the C language, its advantages, and find the most classic hello
World source code, in your ide, knock out and run the first program you wrote.

Then we start to officially learn the language, but remember the experience of everyone first: to learn the language, be sure to write it manually. Anyone who has learned English knows that a word can be read and not necessarily written-believe it is beleive or believe, and receive it as receive and recieve? If you do not write more, you may never be confused. The same is true for learning languages: Do I need to add a semicolon to the last line when defining a struct? Do I need to enclose the braces in struct? How is typedef defined? In the for statement, I must start from 0 or start from 1. Which quotation marks in the middle can be omitted? -- These are things that are easy for beginners to confuse. They can be remembered only when they actually start to bubble their computers and discover their own mistakes. No answers are listed here because the answers to these questions need to be explored by yourself. -- The only thing that throws a book is a dumb, and the only thing that breaks down the keyboard is the bull.

What to write? There are a lot to write. The most direct example is every example in the teaching material: After you understand it, you can write it out of the teaching material. This kind of exercise is very necessary, and it can lay a good foundation for your language-you certainly don't want to find errors after checking hundreds of lines of code, just because the Boundary Problem of the array is not clear, you cannot even discover your mistakes. So don't worry about your keyboard (very cheap, we use dell8115 ). In the process of learning the C language, the most difficult thing to do is to break through the second pulse of Ren du: array and pointer. This is also the essence of C/C ++. C/C ++ Nb is a pointer that is flexible and efficient. It is also criticized because of pointer (the programmer is prone to abuse of pointers, leading to memory leaks and access errors, etc, computer MM also has privacy, don't worry about it ). So here you may want to learn more, think more, write more, and be impatient to eat hot tofu. It also takes time to cook rice. The linked list is written several times more; a group of functions (or encapsulated as an object) are written to process the matrix ). If you have enough time, you 'd better do some exercises after class. In addition
Judge, an online evaluation system, such
Http://acm.whu.edu.cn/wojThe server of the online evaluation system of Wuhan University is also very good, because the simple questions on OJ are also very good hands-on solutions. Here we have a list of most simple questions about woj.Http://acm.whu.edu.cn/blog/tag.php? Tag = % 25e5% 2585% 25a5% 25e9% 2597% 25a8. The advantage of OJ is that, if your code is not rigorous, it is easy to be checked out by the high-intensity test data on OJ.

When you are a beginner, the examples in the book are easy to understand. It is quite normal. This is the beginning of your way of thinking: Try to "read" The program on a computer. It is to train your mind into a CPU and "execute" The program step by step. If necessary, you can use paper as the value of the variable in the memory, "Storage" program running. In this way, you will quickly figure out what the computer mm thinks, and it will be much easier to bubble up. This is very important for training your own way of thinking. After learning C language for a year or two, many people still find it very difficult to convert their ideas into program code, even for the specific implementation steps clearly described-not because they do not understand the syntax (they may have scores close to full marks for the C language test ), but they did not learn the "thinking" Method of Computer mm at all. After learning this way of thinking, you can quickly turn your ideas into program code.

When writing code, pay attention to the Code style. First, compare the following two sections of the Pipeline Code:
Int main () {char a [100];
For (INT I = 0; I <10; ++ I)
{
Scanf ("% s", );
Printf ("Hello % s! \ N ", );
}
Return 0 ;}

Int main (){
Char name [100];
For (INT I = 0; I <10; ++ I ){
Scanf ("% s", name );
Printf ("Hello % s! \ N ", name );
}
Return 0;
}

Which code do you like? You certainly won't like the first paragraph without your conscience: I don't know what to say, but I'm glad to talk about it? Although the first piece of code was intentionally written in that way, it was not exaggerated. This is because this "style" is often seen in the code of beginners ". Beginners often disagree with this. Their reasons are: This code is very short and it doesn't matter. It doesn't matter if you change it later. It doesn't seem to be any different. The above code is really short, even though it is easy to understand like the first paragraph, but you can never write only four or five lines of programs. When the program gets longer, the problem arises: Oh, the compilation is wrong! What's going on? Oh, a parentheses are missing, and a braces are missing. Oh, the running result is incorrect! What's going on? I couldn't find it for a long time. I sent it to Daniel and got it by BS: That's the code. I hope Daniel can help me with this code. It's also a bit self-aware if you want to get the MM! (After a few days, I accidentally saw my code.) who wrote this code? What is so disgusting? -- Therefore, we start from the first line of code to cultivate our own code style. Note the following points in the Code style: 1.
Indent: All statements at the same level are indented. 2. the rational use of spaces and blank lines makes the code clear and easy to read; 3. make the code easier to read by using appropriate annotations. 4. use of brackets; 5. variable naming should be standardized and clear. Baidu and Google will tell you the specific content. Please remember this old saying: Sharpen your knife without mistake!

Finally, the Code is written and the compilation is OK. Double-click it and run it! Collapse! Address 0x00000000 access error, the memory cannot be read (this little brother notes, MM inside change clothes ). Of course, there may be many kinds of errors. The most common is that the input is correct, and the output is incorrect (it is also nonsense ). For example, the objective is to find two solid roots of a quadratic equation. The idea is clear Di, the algorithm is clear Di, and the program is clean Di. The TM answer is wrong di. What's going on? Call! -- It's not a program that calls you, but a program to call. Oh no, it's a debugging program. The programmers who bubble computer mm say that programmers who do not debug can never write good programs. The real good ones are called. Debugging: debugging. I personally know that there is a problem with the program, so where is the problem? This is the debugging work. To put it bluntly, you just need to find something. You can manually insert some statements in the program to pause the program and output the value of the intermediate variable to determine whether the program encountered a problem in a certain step, so as to locate the error; you can also rely on the debugging functions provided by IDE or other debugging tools (such as GDB, run a program in a controllable environment without modifying the source code. For example, you can run a code line of the program at a time to check the value of the variable, change these values, or let the program run to a certain point and then stop ). All in all, it is to locate the error and provide an important clue for the analysis to solve the problem. After locating the problem, you can no longer treat the human brain as a computer. Think about why this problem occurs. If you cannot figure it out, go and ask the big guy who can bring your computer to the server. By accumulating experience, you can also deal with her.

In addition, although it is recommended that you start from the C language, it is best to get started with object-oriented knowledge as soon as possible after you start writing code, which is very helpful for subsequent coding.

Some people say that even the father of C ++ needs to be told about the usage of C ++, so language learning will not end. After laying a solid language foundation, you can read some deeper books and recommend a few good books: the C programming language, the C ++ programming language, C ++ primer, the C ++ standard library, and the C ++ entry classic. The C ++ Standard
Library mainly talks about STL, which is worth seeing. (If you don't learn something useful like STL, it will be sent by day ...).

--

There are a lot of people who have such questions: Now I can soak the computer mm in the ankle and ask her to help me, amount, solve the quadratic equations of one dollar or count the number of words in a file, but if we encounter a more complex problem, such as taking the maze and finding out the longest public substrings of two strings, that is, we are finished. My mm is lost in the maze and there is no food, what should we do? What, baked string? Mao, you have a stick, and the MM needs electric power. So we still need to learn algorithms to save mm from reality. After learning the language, we can look at the concept of algorithms in a narrow sense: An Effective Way to organize computer programs and data and process data to solve problems. The computer language has been organized, but data has to be organized. To give a simple question, how can we organize the sorting of 100 pieces of data? Define 100 variables?
Int a001, a002,..., a100? Of course you won't be so stupid: You have learned arrays! Yes, but as mentioned above, how does this algorithm need to organize the data used in it? The Maze itself can be saved using a two-dimensional array, but how do you organize the steps that you walk through the maze and the forks you encounter? Here we need to use the stack or queue of these more advanced items-This belongs to the category of data structure.

Baidu Baike-> Data Structure: I am using computers to store and organize data. A collection of data elements that have one or more specific relationships with each other. In general, the carefully selected algorithm can bring higher running or storage efficiency. It is often related to efficient search algorithms and indexing technology. I have no standard definition in computer science.

Orz... it looks so tired. We're trying to get a bubble, not to listen to tianshu. Simply put, we need to figure out how to organize data (store, read, process...) in a computer ......) . This is inseparable from algorithms. The construction of a certain data structure requires the support of algorithms. If a good algorithm does not have the support of a suitable data structure, it is like a Popeye eating cabbage, and it can be used as a top p.

To learn about the data structure, you also need a good book (not to mention the reason, so you can save some time to talk about it). Here, we recommend the data structure of the teacher Yan Weimin of Tsinghua University. or Data Structure C ++ language description. You can learn the most popular data structures, such as sequence tables, stacks, queues, strings, trees, and graphs. As for how to learn it, read a book (p.s. We suggest learning Graph Theory in discrete mathematics when learning graphs ). If you want to learn algorithms well, these data structures must be mastered. If you want to master these data structures well, you must write them one way since ancient times. After understanding the implementation method of a Data Structure, write your own code to implement it so that you can truly master it. When you watch the TV series, heroes don't have to watch little books before changing Nb. They all have to work hard every day.

It should be noted that what we learn here is the basis of the data structure, which cannot meet the needs of all algorithms. We often need to transform them, such as the birth of sequence tables and trees-line tree ~ This fully proves the correctness of the hybrid advantage theory. Another example is the suffix array, another example is the cross linked list, and another example is the suffix array... (I have no inventory in my stomach. I 'd like to add it to Daniel )... These special data structures are rarely used in common learning. Therefore, we need to do more ACM/ICPC questions and continue to accumulate.

In addition, we recommend that you use the object-oriented method to implement a data structure and write a class instead of using a bunch of loose functions. (This tutorial is really ooxx)

--

After you finally instruct the computer mm to queue, plant trees, and draw pictures, you can start to cultivate algorithms.

Baidu Baike-> algorithm: The English name is algorithm, which is a series of clear instructions for solving the problem. That is to say, the required output can be obtained for certain standard input within a limited time.

Orz... the last few words are easy to say, and I don't want to think about how thick this brick is in introduction to algorithms. Which of the following articles about the art of computer programming does knuth have... Let's take a look at these things first... Similarly, you cannot learn all algorithms, but you still need to do more questions and accumulate them.

--

Finally, I will mention some ICPC-related things.

1. OJ, online judge
Online evaluation systems, including vijos, usaco, poj, and zoj. Provides a series of questions, allows the viewer to submit the corresponding source code and test it, whether it can fully meet the requirements of the questions.
Taking the online evaluation system woj of Wuhan University as an example
Http://acm.whu.edu.cn/wojAfter registering and logging on, you can try to open
Http://acm.whu.edu.cn/oak/problem/problem.jsp? Problem_id = 1001
This is the simplest question. Input A, B, and the sum of A and B (most OJ have this question for testing)
(For more information about the hint part of this page, read the FAQ:
Http://acm.whu.edu.cn/oak/faq.html)
Click the submit button at the bottom of the page to go to the webpage with a large text box, paste your code into the text box, and click the submit button below
Then the browser will submit your code to the server for testing and automatically go to the result page for viewing.
If the corresponding result is accepted (AC for short), you are correct about this question. For other information, see the description in the FAQ.

~ Some OJ links
  
Http://acm.timus.ru/(Foreign)
  
Http://acm.hdu.edu.cn/Hangzhou University of Electronic Science and Technology
  
Http://acm.pku.edu.cn/JudgeOnline/Peking University
  
Http://acm.nenu.edu.cn/OrHttp://acm.hrbeu.edu.cn/Harbin Project
  
Http://acm.jlu.edu.cn/jojJilin University
  
Http://acm.tju.edu.cn/Tianjin University
Http://acm.whu.edu.cn/Wuhan University
  
Http://acm.sgu.ru/Russian University of San salatov online question bank
  
Http://acm.mipt.ru/judge/bin/problems.pl? Lang = enMoscow Institute of Physical Technology
  
Https://spoj.sphere.pl/Gdansk Polytechnic University, Poland
  
Http://acm.uva.es/Universidad in Spain
De Valladolid online question

2. See the log I wrote earlier.Http://www.felix021.com/blog/read.php? 1318

Transferred from Wuhan UniversityFelixDaniel blog

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.