ArticleslgStudy

computer science

Competitive programming

Competitive programming is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Competitive programming rather than just read about it. In short: Competitive programming, or sport programming, is a mind sport involving participants trying to program according to given specifications. The contests are usually held over the Internet or a local network.

Competitive programming — main illustration
Competitive programming — illustration

Key takeaways

  • Competitive programming belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Competitive programming to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Competitive programming from memory before moving on to harder problems.

Reference excerpt

Competitive programming, or sport programming, is a mind sport involving participants trying to program according to given specifications. The contests are usually held over the Internet or a local network. Competitive programming is recognized and supported by several multinational software and Internet companies, such as Google and Meta. A programming competition generally involves the host presenting a set of logical or mathematical problems, also known as puzzles or challenges, to the contestants (who can vary in number from tens or even hundreds to several thousand). Contestants are required to write computer programs capable of solving these problems. Judging is mostly based on the number of problems solved and the time spent writing successful solutions, but may also consider other factors such as output quality, execution time. memory usage, and program size.

History One of the oldest contests known is the International Collegiate Programming Contest (ICPC) which originated in the 1970s and has grown to include 88 countries in its 2011 edition. From 1990 to 1994, Owen Astrachan, Vivek Khera and David Kotz ran one of the first distributed, internet-based programming contests inspired by the ICPC. Interest in competitive programming has grown extensively since 2000 to tens of thousands of participants (see Notable competitions), and is strongly connected to the growth of the Internet, which facilitates holding international contests online, eliminating geographical problems.

Overview The aim of competitive programming is to write computer programs which are able to solve given problems. A vast majority of problems appearing in programming contests are mathematical or logical in nature. Typical such tasks belong to one of the following categories: combinatorics, number theory, graph theory, algorithmic game theory, computational geometry, string analysis, discrete mathematics and data structures. Problems related to constraint programming and artificial intelligence are also popular in certain competitions. Irrespective of the problem category, the process of solving a problem can be divided into two broad steps: constructing an efficient algorithm, and implementing the algorithm in a suitable programming language (the set of programming languages allowed varies from contest to contest). These are the two most commonly tested skills in programming competitions. In most contests, the judging is done automatically by host machines, commonly known as judges. Every solution submitted by a contestant is run on the judge against a set of (usually secret) test cases. Normally, contest problems have an all-or-none marking system, meaning that a solution is "Accepted" only if it produces satisfactory results on all test cases run by the judge, and is rejected otherwise. However, some contest problems may allow for partial scoring, depending on the number of test cases passed, the quality of the results, or some other specified criteria. Some other contests only require that the contestant submit the output corresponding to given input data, in which case the judge only has to analyze the submitted output data. Online judges are online environments in which testing takes place. Online judges have rank lists showing users with the biggest number of accepted solutions and/or shortest execution time for a particular problem.

Notable competitions

Algorithm competitions

In most of the above competitions, competitions are usually organized in several rounds. They usually start with online rounds, which conclude in the onsite final round. The top performers at IOI and ICPC receive gold, silver and bronze medals. In the other contests, cash prizes are awarded to the top finishers. The competitions also attract the interest of recruiters from multiple software and Internet companies, which often reach out to competitors with potential job offers.

Artificial intelligence and machine learning List may be incomplete

Contests focusing on open-source technologies List may be incomplete

Online platforms The programming community around the world has created and maintained several internet-resources dedicated to competitive programming. They offer standalone contests with or without minor prizes. Users will typically be assigned a rating based on their performance on said contests. The archives of past problems are popular resources for training in competitive programming. There are several organizations that host programming competitions on a regular basis. These include:

Benefits and criticism Participation in programming contests may increase student enthusiasm for computer science studies. The skills acquired in ICPC-like programming contests also improve career prospects, as they help to pass the "technical interviews", which often require candidates to solve complex programming and algorithmic problems on the spot. There has also been criticism of competitive programming, particularly from professional software developers. One critical point is that many fast-paced programming contests teach competitors bad programming habits and code style (like unnecessary use of macros, lack of OOP abstraction and comments, use of short variable names, etc.). Also, by offering only small algorithmic puzzles with relatively short solutions, programming contests like ICPC and IOI do not necessarily teach good software engineering skills and practices, as real software projects typically have many thousands of lines of code and are developed by large teams over long periods of time. Peter Norvig stated that based on the available data, being a winner of programming contests correlated negatively with a programmer's performance at their job at Google (even though contest winners had higher chances of getting hired). Norvig later stated that this correlation was observed on a small data set, but that it could not be confirmed after examining a larger data set. Another sentiment is that rather than spending time on excessive competing by solving problems with known solutions, high-profile programmers should instead invest their time in solving real-world problems.

… excerpt ends here. Continue reading the full article.

Illustrations

Competitive programming: Petr Mitrichev (left) and Gennady Korotkevich (right), two prominent competitive programmers during the 2013 Yandex algorithm cup
Petr Mitrichev (left) and Gennady Korotkevich (right), two prominent competitive programmers during the 2013 Yandex algorithm cup

Worked examples

Example 1 — a first encounter with Competitive programming

Start with the simplest possible case. Write down what Competitive programming claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Competitive programming before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Competitive programming ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Competitive programming

In research
Competitive programming appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Competitive programming in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Competitive programming is common in secondary-school and first-year university syllabi. It links to neighbouring topics Computer science competitions, Programming contests, so understanding it makes those chapters shorter.
In everyday life
Look for Competitive programming outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Competitive programming” →

How to study Competitive programming in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Competitive programming means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Competitive programming out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Competitive programming in simple terms?

Competitive programming, or sport programming, is a mind sport involving participants trying to program according to given specifications. The contests are usually held over the Internet or a local network.

Why does Competitive programming matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Competitive programming?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Competitive programming.

Tags

  • Computer science competitions
  • Programming contests

Keep exploring