This summer, I spent more than
coding solutions to
Over 90 days of dedication, diligence, and problem-solving, I gained over
on DMOJ alone!
This summer, I spent more than
coding solutions to
Over 90 days of dedication, diligence, and problem-solving, I gained over
on DMOJ alone!
I hope that this website will serve as a
in your competitive programming journey,
whether you are an absolute beginner or
proficient programmer.
My Competitive Programming Corner will be your source of
Here, you will find:
Scroll up and then click the arrow button on the right to navigate to the second page
Competitive programming requires logic, problem-solving, and knowledge of data structures to code solutions to a wide range of problems.
The common languages used in competitive programming are Python, Java, and C++, of which python is the most simple and C++ is the most efficient.
A typical competitive programming problem consists of three parts:
Here is an example of a simple addition question derived from A Plus B on DMOJ.
The problem description:
Tudor is sitting in math class, on his laptop. Clearly, he is not paying attention in this situation. However, he gets called on by his math teacher to do some problems. Since his math teacher did not expect much from Tudor, he only needs to do some simple addition problems. However, simple for you and I may not be simple for Tudor, so please help him!
To understand the task required, you must thoroughly peruse (read) the problem description as if
you misread the
statement, no amount of careful programming will result in an accepted solution.
Here is the input specification of A plus B:
The first line will contain an integer N (1 ≤ N ≤ 100 000), the number of addition problems Tudor needs to do. The next N lines will each contain two space-separated integers whose absolute value is less than 1 000 000 000, the two integers Tudor needs to add.
Now the output specification of A plus B:
Output N lines of one integer each, the solutions to the addition problems in order.
If you are using java or c++ where data types are subjective, pay attention to the restraints as
otherwise, you may
encounter Integer overflow (an error where an Integer is too large for the data type and should
be stored into a Long
data type instead).
Finally, we have the sample cases:
Sample Input
2
1 1
-1 0
Sample Output
2
-1
Normally, there will be at least one example that explains the input case, the correct output case, and the solution.
As you progress into the more difficult areas of competitive programming, you may find yourself
stuck on a problem for
hours at a time. However, if you ever need a hint, you may first discover the problem type,
which alludes to the nature
of the solution required.
For example, for the question A plus B above, the problem type is Simple Math.
Afterwards, you may also take a look at the editorial, which describes the essence of the
solution.
Important!
The editorial does not display the solution code for the question, so you will still have to
complete the implementation
yourself.
Warning!
Not every problem has an editorial. Regardless, you should endeavour to solve the problem
without the editorial for at
least an hour to develop your competitive programming abilities.
The competitive programming problem types fall into these following categories: data structures,
sorting and searching,
dynamic programming, graph theory, greedy algorithms, backtracking and recursion, string
algorithms and Math.
Most programming problems require some experience in Math; particularly contest Math; as it
educates you on essential
problem solving strategies. For example, the typical method for determining if a given positive
integer is prime is
testing division of all the numbers from 1 to that number. However, knowledge of contest math
strategies would help you
solve the question more efficiently to satisfy the time restraints as an alternative solution
involves Eratosthenes’
Sieve.
In addition, some seemingly difficult problems such as TWO KNIGHTS (CSES) turn out to be Math
questions which can be solved
by determining the correct algebraic formula.
Competitive programming has an emphasis on efficiency, simplicity, and accuracy. By learning
more about different data
structures, algorithms, and logic operations, you will be able to code faster solutions that do
not require extensive
code.
A rule of thumb is that if you have more than 3 nested for loops, your solution is definitely
not the intended solution,
is probably incorrect, and will not pass the time limit. In addition, as encouraged for learning
in general, you should
be able to easily explain your solution to someone else if it is concise and properly
structured.
Overall, competitive programming is the type of skill that you improve at if you regularly
practice by compeleting more problems to test your knowledge of data structures, methods, and
algorithms.
My competitive programming journey began in grade 4 and since then, I have progressed from Python to Java and learned a
variety of algorithms which allow me to solve problems with difficulty levels of up to CCC Senior P3.
Although I have been solving competitive programming problems for 4 years now, I only began to seriously practice for
the CCC and related competitions for the last half of the year. During these previous 6 months, I elevated my knowledge
of data structures and related manipulations, dynamic programming, and graph theory. Currently, the most difficult
problem that I have solved was a 10 pointer, which correlates to CCC Junior P5.
To anyone attempting to excel at competitive programming competitions, my first advice is to practice a variety of
problems often. Every time you complete a new question, you sharpen your skills a little bit by using a new concept,
reviewing previous concepts, or discovering a new technique.
My second advice is to review other users’s solutions as especially if you are practicing on your own without any
external guidance, viewing faster code and analyzing WHY they are more efficient or concise than yours will help you
improve your skills and also reveal some common tricks competitive programmers use to keep their code adequately
simplistic.
My final tip is to consistently practice competitive programming problems instead of suddenly grinding 10 problems in
one day each week, spread out by working on a set amount of problems every week with a certain amount of time allocated
each day. If you complete a bulk of problems in a short amount of time and then wait for a long time before your next
work period, you risk forgetting what you learned and may develop a dislike for programming as you dedicate an entire
day for it each week and lack variety in your workload.
The Don Mills Open Judge is my favourite resource to use as it has a huge library of problems from national competitions such as the CCC, local school competitions, and challenging questions created by community users. In addition, DMOJ was created by Canadian high school students and many Canadian competitive programmers (even members of the international team) use it to practice. I also like the interface as it is quite simple to use and detailed at the same time as it allows users to view other people’s accepted solutions and see problem statistics.
USACO is also a notable resource which I often use to practice problems. Their website showcases the problem archive from their monthly competitions which have 4 levels of difficulty (Bronze, Silver, Gold, and Platinum). However, USACO does not provide many community features such as commenting and viewing each other’s solutions.
VJudge takes its problems from a variety of sources, including DMOJ, USACO, CSES, and CodeForces. If you like having all your sources in a central library, vJudge is definitely a suitable platform for you! Personally, I do not like VJudge’s platform; however, I encourage you to try the application out for yourself before making any judgments.
I do not use CSES regularly; however, it contains a library of very generic problems categorized into topics such as dynamic programming. In fact, it contains many problem templates for problem creators to develop their questions on.
Although I do not use CodeForces often, I do know that it has a large amount of problems and hosts weekly timed contests every Saturday. It is definitely a suitable option for a problem resource!
Written by Antti Laaksonen, the Competitive Programmer’s Handbook is a thorough guide on competitive programming algorithms and concepts which will definitely prove to be a useful resource when you reach more difficult areas of competitive programming. It is free and can be reached using this link: