Intro to Competitive Programming

Samar Anand
3 min readJun 8, 2020

Every coder wants to be part of competitive programming formally we call it as CP. but what many beginners fear about is staring it as I used to do so. First whats the mean of competitive programming is? basically it is a type of mind sports in which contestants participate in a contest in which few logical and mathematical problems are given and participants need to solve it by writing source codes in the span of time. Nowadays it is very popular among young coders.

we have many online platforms for competitive programming but Codeforces, Codechef, AtCoder etc. are best. They are best for the collection of their questions. Codeforces is famous for their 2–3 hr contest in every 3–4 days while CodeChef is famous for Long Challenge which is conducted for 10 days. Same as at AtCoders and HackerEarth where the monthly challenge is conducted. and after contest, they used to release editorial that is the solution of all problems from their newbies can learn and grow.

How to Start?

  1. Learn a programming language. Best choice for CPs is C++ but you can learn Java too. also, Learn about the STL of C++.
  2. Learn Data Structure
  3. Learn Algorithms

why C++? I say C++ because all the CP platforms accept the language C++ and also releases their editorial in C++. many good books for CPs are written in C++.

few best books

  1. Competitive Programmer’s Handbook
  2. Competitive Programming 3 by Steven Halim & Felix Halim
  3. Guide-to-Competitive-Programming-Learning-and-improving-Algorithms-through-Contests

Contestants need to be very fast so they use what we call it as templates. Templates are few lines which are used frequently so coders write them and use the micros in the place.

#include “bits/stdc++.h”
using namespace std;
#define pb push_back
#define F first
#define S second
//#define biGinf 9e+18
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define inpv(v) for(auto &x:v) cin>>x
#define otpv(v) for(auto &x:v) cout<<x<<nwl
#define otpv2(v) for(auto &x:v) cout<<x<<” “
#define CASES int tt;cin>>tt; while(tt — )
#define for0(i,n) for(int i=0; i<n; i++)
#define for1(i,n) for(int i=1; i<n; i++)
#define sz(v) (int)(v).size()
using vi = vector < int >;
using vii = vector < vi >;
using pii = pair < int , int >;
using vpii = vector < pii >;
using int64 = long long;
//const int64 biGinf = 9e+18;
//const string yo = “YES”, no = “NO”;
const int inf = 2e9 + 7;
const char nwl = ‘\n’;

int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
//ur code

return 0;
}

So it's all about the introduction of CP. also a good editor and coding environment helps. Some good coders use OS like Ubuntu and text editor like Sublime Text Editor. In place of the terminal, we can install guake in Ubuntu because it starts with one button F12 and very helpful. we can set up an Ubuntu environment for checking edge cases with random values. we can save snippets in the sublime text editor so don't need to copy and paste frequently. There are lots of stuff which matters but the main thing is that how much a guy practices. from start to last it's all about practices with good questions.

--

--

Samar Anand

"Software Engineer & Blogger. Sharing tech insights & tips. Follow for expert perspectives on software development. - Samar Anand"