Guide to Competitive Programming
Abstract
The purpose of this book is to give you a comprehensive introduction to modern
competitive programming. It is assumed that you already know the basics of programming,
but previous background in algorithm design or programming contests
is not necessary. Since the book covers a wide range of topics of various difficulty,
it suits both for beginners and more experienced readers.
Programming contests already have a quite long history. The International
Collegiate Programming Contest for university students was started during the
1970s, and the first International Olympiad in Informatics for secondary school
students was organized in 1989. Both competitions are now established events with
a large number of participants from all around the world.
Today, competitive programming is more popular than ever. The Internet has
played a significant role in this progress. There is now an active online community
of competitive programmers, and many contests are organized every week. At the
same time, the difficulty of contests is increasing. Techniques that only the very best
participants mastered some years ago are now standard tools known by a large
number of people.
Competitive programming has its roots in the scientific study of algorithms.
However, while a computer scientist writes a proof to show that their algorithm
works, a competitive programmer implements their algorithm and submits it to a
contest system. Then, the algorithm is tested using a set of test cases, and if it passes
all of them, it is accepted. This is an essential element in competitive programming,
because it provides a way to automatically get strong evidence that an algorithm
works. In fact, competitive programming has proved to be an excellent way to learn
algorithms, because it encourages to design algorithms that really work, instead of
sketching ideas that may work or not.