01st basics of ACM/ICPC Competition

Source: Internet
Author: User

I. ACM/ICPC competition features

ACM/ICPC (International College StudentProgramDesign Competition) isAlgorithmDesign-oriented program design competitions do not involve specific application technologies.

The ACM/ICPC competition takes the form of a team. Each team consists of three members and uses a single computer to solve problems. Generally, the number of questions in each game is 6 to 10, which is ranked based on the number of completed questions in each team and the penalty. When a question is submitted, it is called completion. When the time from the competition to the successful submission is the basic penalty for the question, in addition, each submission failure of a question will increase the penalty by 20 minutes. That is to say, teams should try their best to solve the most problems with the fastest speed and the least number of failures.

Ii. Input and Output Processing
Generally, standard input and output are used to read input and output. The format and value range of input and output are described in detail in the question, the program must strictly abide by the input and output formats specified by the question.

In terms of the input and output processing of the competition questions, there are some common methods for some common situations.

1. Input and Output of multiple Test Cases

Some questions only contain one test case in one input. That is to say, each time the program runs, only one question is included. Some questions include multiple test cases in one input. That is to say, each time a program runs, multiple questions need to be calculated.

For multi-use cases, the number of cases to be calculated is usually input first, and then the input data of each test case is input in sequence, however, the program does not need to wait until all test cases are computed before outputting the calculation results of all test cases. Instead, it can read a test case, output a result, and then read a test case, output another result. Therefore, you can use the following input mode for multi-use case input questions:

Take C ++ as an example:

Int N;

Cin> N;

For (INT I = 0; I <n; I ++)

{

Read test case data

Computing

Output computing result

}

2. End judgment of single test case Input
The main problem with single-case input is how to know when the input ends.

Some questions will specify a special input value as the end mark of the input, which is easier to handle. You only need to judge whether the read content is the agreed end value after reading.

Some questions do not specify special input values, but end with an EOF. If you read data from a file stream, when you read the end of the file, the input returns EOF. If you read data from the keyboard, press Ctrl + Z to indicate EOF on a Windows terminal. In this case, you can use the following input mode:

Take C ++ as an example:

Int M, N; // assume that you want to input an integer pair consecutively.

While (CIN> m> N)

{

Process INTEGER (m, n)

}

Take the C language as an example:

Int M, N;

While (scanf ("% d", & M, & n) = 2)

{

Process INTEGER (m, n)

}

Iii. Data Structure Design
The upper limit of data size has been given in many questions, so you can easily define the data structure in an array. However, you should also note that some questions do not explicitly specify the upper limit of the data, so you must not blindly define the array size.

For example, in question 1070 (polynomial summation), the number of items in the input polynomial is not described. In this case, it is not recommended to use arrays to represent the polynomial. Unless you are lucky enough, the size of the opened array can be tested by all test cases.

In addition to the general array or linked list structure, STL is also a provisioner for contestants who use C ++. Full Use of STL can effectively improve programming efficiency and correctness.

Iv. Considerations for test cases
Examples of test cases are usually provided in the test questions. This is usually used to test our own program. Many contestants often calculate the test case sample correctly, will think that their program is correct.

In fact, the example of a test case is only a test case. The actual test cases used for testing often cover various limits and boundaries, and sometimes the number of test cases is relatively large, the same test case is even repeated. Therefore, our program can pass the sample test and may not pass all test cases. On the one hand, we must fully consider all possible limits and boundaries, on the one hand, the program should have sufficient efficiency.

 

This article from the csdn blog, reproduced please indicate the source: http://blog.csdn.net/camel_flying/archive/2009/08/17/4454162.aspx

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.