11

competative programming

Embed Size (px)

DESCRIPTION

How to prepare for competitive programming contests?

Citation preview

Page 1: competative programming
Page 2: competative programming

OutlineOutline

What is programming contest ? What is and which are online judges ? Which programming languages are better for

this ? Header of C++14 STL in C++14 Fast input and output in C++14 Time complexity Some standard algorithms Some contests

Page 3: competative programming

What is programming What is programming contests….?contests….?

Programming contest are nothing but the programming exams .

Some colleges , some companies or some organizations are interested to takes programming contests on to find out leading programmers .

These contests helps to improve our skill and algorithm.

Which further helps to improve our problem solving skill.

Page 4: competative programming

What is and which are What is and which are online judges… ?online judges… ?

Online judges are nothing but the online compilers , they not only compile the program but also check running time complexity , space complexity according to constrains of program.

These judges also evaluate the rank of users according to their points.

Some Online judges: SPOJ CODECHEF CODEFORCES HACKEREARTH HACKERRANK TOPCODER

Page 5: competative programming

Which programming languages Which programming languages are better for online contests…?are better for online contests…?

These Online judges supports 40+ programming languages. We have to choose the language in which we are more

comfortable as well as the running time performance and library of that language should be as large as possible

Some popular programming languages : C C++’14 Python 2.7,3.0 Java PHP Ruby Perl Delphi ADA and many others

Page 6: competative programming

Header files of c++14Header files of c++14

#include<bits/stdc++.h> This header is used from c++ 4.8 of gcc NO need to include any other header files when we include this one.

Page 7: competative programming

STL in C++14STL in C++14

There are some Standard Templates Library in c++14 Set Queue Pair Map Dequeue Stack

Page 8: competative programming

Fast IO in C++14Fast IO in C++14

Cin > scanf > gets > getchar > getchar_unlock

Cout > printf > puts > puchar > putchar_unlock

When these is very large input set then we have to go for fast IO in c++14

For very large input set one can use file or fast IO code Std::ios::sync_with_stdio(false); Cin.tie(NULL); Manual use of getchar_unlock & putchar_unlock to de

Page 9: competative programming

Time ComplexityTime Complexity

O(1) : For all mathematical formulaes

O(log n ) : For AVL & RBT

O(n log log n) :Sieve of Eratosthenes of prime generation

O(n log n ) : For divide & conquer algo.

O(n2) : For brute force

O( 2^n) :For Polynomial time

Page 10: competative programming

Important algorithms Important algorithms

Followings are some algorithms with might be helpful in online programming

Backtracking : N-queen problem Tree traversal

Greedy : Prims Krushkal

Dynamic programming : Knapsack: Travelling sells man problem

Number theory : Euclidean for GCD and LCM Sieve of Eratosthenes for prime number generation Chines Reminder and Rabbine millar for prime number checking

Page 11: competative programming

Some contestsSome contests

ACM-ICPC

Facebook HackerCup

Google CodeJam

IOI