Introduction to Competitive Programming
Major CP Platforms
Competitive programming is practiced on several online judges, each with distinct problem styles, contest formats, and communities. Understanding each platform's strengths helps you structure your practice.
Codeforces
The most active CP platform worldwide. Hosts 2–3 rated contests per week in divisions: Div 1 (1900+), Div 2 (0–2099), Div 3 (<1600), and Div 4 (<1400). Problems range from implementation to deep math and advanced data structures. The editorial culture and comment discussions are unmatched.
Best for: Regular practice, rating tracking, editorial learning.
AtCoder
Japanese platform known for mathematically elegant problems. Contests: ABC (beginner), ARC (regular), AGC (grand). Problems often require clean mathematical observations rather than heavy implementation. The AtCoder Library (ACL) is a gold-standard reference for competitive programming data structures.
Best for: Mathematical thinking, clean problem design, library reference.
ICPC
The International Collegiate Programming Contest is team-based (3 people, 1 computer). Regional → national → world finals pipeline. Problems span all areas: geometry, strings, flows, DP, number theory. The team dynamic adds strategy: who solves what, when to print, balloon tracking. Training typically involves weekly 5-hour practice contests with your team.
Best for: Team collaboration, contest strategy, breadth of topics.
IOI / National Olympiads
The International Olympiad in Informatics targets pre-university students. Problems are fewer (3 per day) but deeper—often requiring subtask-based partial scoring. Common topics: interactive problems, output-only tasks, and problems with heavy optimization requirements. National olympiads (USACO, JOI, COCI) serve as qualifiers.
Best for: Deep problem-solving, partial scoring strategies, optimization.
Rating Systems Explained
Understanding how ratings work helps you set realistic goals and avoid tilting after bad performances.
Codeforces Elo-like System
Codeforces uses a modified Elo system. Your rating changes based on your rank relative to your expected rank (computed from the ratings of all participants). Key properties:
- New accounts get a boost: Your first 6 contests have inflated rating changes to calibrate you quickly.
- Volatility matters: If you haven't competed recently, your expected performance is less certain, leading to bigger swings.
- Penalty is speed-based: Solving a problem at minute 5 vs minute 90 matters. Failed submissions add 10-minute penalties.
- Delta formula: Δ = K × (actual_rank − expected_rank), where K decreases as you play more contests.
AtCoder Rating
AtCoder uses a similar system but with a performance rating concept. After each contest, you receive a "performance" value. Your rating converges toward your average performance over time. The key difference: AtCoder explicitly shows your performance per contest, making it easy to track progress.
Rating Tiers Comparison
Codeforces Tiers
- ■ Newbie: 0–1199
- ■ Pupil: 1200–1399
- ■ Specialist: 1400–1599
- ■ Expert: 1600–1899
- ■ Candidate Master: 1900–2099
- ■ Master: 2100–2299
- ■ Grandmaster: 2400+
AtCoder Tiers
- ■ Gray: 0–399
- ■ Brown: 400–799
- ■ Green: 800–1199
- ■ Cyan: 1200–1599
- ■ Blue: 1600–1999
- ■ Yellow: 2000–2399
- ■ Orange: 2400–2799
- ■ Red: 2800+
Effective Practice Strategy
Grinding problems randomly is the #1 mistake. Here's a structured approach that actually works, based on the experience of many competitive programmers who've gone from gray to purple.
The +200 Rule
Practice problems rated 200 points above your current rating. If you're 1400, solve 1600-rated problems. This ensures you're being challenged without being completely lost. Use Codeforces Problemset filters: set the rating range and sort by number of solvers (descending) to find accessible problems at that difficulty.
Upsolving Protocol
After every contest, upsolve at least one problem you couldn't solve during the contest:
- Spend 30–60 minutes attempting it with fresh eyes (no editorial yet)
- If still stuck, read the editorial but don't look at code
- Implement the solution yourself from the editorial idea
- If your implementation fails, then compare with editorial code
- Tag the problem with the technique used for future review
Topic-Focused Blocks
Dedicate 1–2 week blocks to specific topics. For example:
- Week 1–2: Binary search (on answer, on sorted arrays, parametric search)
- Week 3–4: Graph BFS/DFS (connected components, bipartite check, cycle detection)
- Week 5–6: Basic DP (knapsack, LIS, grid DP, bitmask DP intro)
- Week 7–8: Number theory (primes, sieve, GCD/LCM, modular arithmetic)
Within each block, solve 15–25 problems of increasing difficulty. Track your solve rate and time.
Contest Workflow
How you approach a contest matters as much as what you know. Here's a typical workflow for a Codeforces Div 2 contest (6 problems, 2 hours):
Pre-contest (5 minutes before)
- Open your template file, compile it once to verify
- Open the contest page, have the problem statements ready
- Close all distractions—no Discord, no YouTube
During Contest
Post-contest (same day)
- Review problems you solved — could you have been faster?
- Upsolve the first unsolved problem within 24 hours
- Read editorials for all remaining problems, even if you won't implement them
- Add new techniques to your personal notes/cheat sheet
Rating Progression Roadmap
Here's a realistic roadmap for going from beginner to expert on Codeforces. Times assume consistent practice (1–2 hours daily, 2+ contests per week).
Gray → Green (0–1399): 1–3 months
- Master basic syntax, loops, arrays, strings, sorting
- Learn greedy algorithms and basic math (GCD, primes, modular arithmetic)
- Solve 100+ Div 3/4 problems
- Key resource: USACO Guide Bronze/Silver sections
Green → Cyan (1400–1599): 2–4 months
- Binary search, two pointers, prefix sums
- BFS/DFS, basic graph algorithms
- Introductory DP (knapsack, LIS, coin change)
- Segment trees (point update, range query)
- Solve 200+ problems, with 50+ at 1400-1600 rating
Cyan → Blue (1600–1899): 4–8 months
- Advanced DP: bitmask, digit, tree DP
- Graphs: shortest paths (Dijkstra, Floyd), MST, topological sort
- Number theory: Euler's totient, CRT, extended GCD
- String algorithms: KMP, Z-function, hashing
- Data structures: Fenwick tree, DSU, sparse table
Blue → Purple (1900–2099): 6–12 months
- Segment tree with lazy propagation, persistent structures
- Heavy-light decomposition, centroid decomposition
- FFT/NTT for polynomial multiplication
- Advanced math: Möbius inversion, generating functions
- Flow algorithms, matching, advanced geometry
Common Beginner Mistakes
Avoid these pitfalls that slow down thousands of competitive programmers:
1. Only Solving Easy Problems
Solving 500 problems rated 800 won't make you better. You must consistently work at the edge of your ability. If you're solving >80% of problems you attempt, you need to increase difficulty.
2. Not Reading Editorials
Some people refuse to read editorials out of pride. After a genuine effort (30-60 min), reading the editorial is the most efficient way to learn new techniques. The editorial teaches you the thought process, not just the solution.
3. Ignoring Implementation Speed
In contests, speed matters. Practice typing your template from memory. Use macros for common patterns. Time yourself on problems you know how to solve—your implementation should be near-instant.
4. Language Wars
Use C++ for competitive programming. Period. Python is too slow for most problems (100× slower). Java works but has verbose I/O and higher constant factors. C++ gives you STL, fast I/O, and the best constant factors. Every serious competitive programmer uses C++.
5. Not Using Version Control
Keep a Git repository of all your contest solutions organized by platform and contest. This lets you search past solutions when you encounter similar problems. Many top competitors maintain public GitHub repos of their solutions.