Skip to content

Competitive Programming Beginners Guide #47

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions docs/CompetitiveProgramming.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# This document is to guide those people who want to get started or have just started with competitive programming.

**You will need to show motivation:**
Languages that should be used
a.C/C++/JAVA (your choice)
b.We will focus on C++, JAVA is slow (one big advantage of JAVA is Big Integers, we will see later)
c.C++ is like superset of C with some additional tools. So, basically if you have knowledge of C, you are ready to d.code in C++ as well. Otherwise go back and learn how to write codes in C/C++
d.Sometimes knowledge of PYTHON is helpful when you really need big integers.

**PARTICIPATE PARTICIPATE PARTICIPATE(the only mantra)**

**1.SPOJ**: Its a problem Archive (recommended for all beginners
a.Start with problems having maximum submissions. Solve first few problems (may be 20). Build some confidence. Then start following some good coders (check their initial submissions). Then start solving problems topic wise
b.Never get stuck for too long in the initial period. Google out your doubts and try to sort them out or you can discuss with someone (ONLY IN THE BEGINNING).
c.Before getting into live contests like codeforces or codechef, make sure that you have solved about 50-70 problems on SPOJ.
**2.CodeChef:** Do all the three contests every month. Do participate in CodeChef LunchTime for sure.
Even if you are unable to solve a problem do always look at the editorials and then code it and get it accepted (this is the way you will learn).
And even if you are able to do it, do look at the codes of some good coders. See how they have implemented. Again you will learn.
Same point apply to TopCoder and Codeforces as well.
**3.Codeforces**: 4 to 5 short contests of 2 hour in a month (Do them once you develop some confidence).
**4.TopCoder**: Once you have proper experience and you can write codes very fast.


**Online Programmming Contests:**
You write codes and submit them online . The judge runs your code and checks the output of your program for several inputs and gives the result based on your program’s outputs.You must follow exact I/O formats. For example, do not print statements like : “please enter a number”, etc :P

Each problem has constraints:

Properly analyse the constraints before you start coding.

Time Limit in seconds (gives you an insight of what is the order of solution it expects) -> order analysis(discussed later).
The constraints on input ( very imp ): Most of the time you can correctly guess the order of the solution by analysing the input constraints and time limit .
Memory Limit ( You need not bother unless you are using insanely large amount of memory).


**Types of errors you may encounter apart from wrong answer:**
**Run Time Error (Most Encountered)**
1.Segmentation fault ( accessing an illegal memory address). You declared array of smaller size than required or you are trying to access negative indices .
Declaration of an array of HUGE HUGE(more than 10^8 ints) size -_- .
Dividing by Zero / Taking modulo with zero :O .
USE gdb ( will learn in coming lectures )
**2.Compilation Error**
You need to learn how to code in C++.
USE GNU G++ compiler or IDEONE(be careful to make codes private).
**3.Time Limit Exceed(TLE)**
4.You program failed to generate all output within given time limit.
5.Input Files are not randomly generated , they are made such that wrong code does not pass.
6.Always think of worst cases before you start coding .Always try to avoid TLE.
7.Sometimes a little optimizations are required and sometimes you really need a totally new and efficient algorithm (this you will learn with time).
8.So whenever you are in doubt that your code will pass or not .Most of the time it won’t pass .
9.Again do proper order analysis of your solution .