> ## Documentation Index
> Fetch the complete documentation index at: https://resources.devweekends.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Competitive Programming Mastery

> The ultimate strategic guide to dominate Codeforces and ICPC with pattern recognition and winning strategies

# Competitive Programming Mastery

![CP Mastery Path](https://mintcdn.com/devweeekends/AEOaWh79Ur7CdHHv/images/courses/cp/cp-mastery-path.svg?fit=max\&auto=format\&n=AEOaWh79Ur7CdHHv\&q=85\&s=6715f1d69d26be23f3cf957755a283bb)

> **This isn't just another algorithms course.** This is a strategic battle plan to take you from solving Div2A problems to crushing Div1 and qualifying for ICPC World Finals. Every chapter is designed with one goal: **make you win.**

> [!NOTE]
>
> **Course Goal**: Take you from **Newbie (800)** to **Expert (1600+)** on Codeforces and prepare you for **ICPC Regionals** within 6-12 months of dedicated practice.

***

## The Winning Formula

Most people practice CP wrong. They solve random problems, never upsolve, and wonder why they plateau. Here's the formula that actually works:

```
Rating Growth = Pattern Recognition × Problem Quantity × Upsolving × (1 / Random Solving)
```

> **Pattern Recognition**
>
> 80% of CF problems use just 15 core patterns. Master them and you'll "see" solutions instantly.

> **Strategic Practice**
>
> Solve problems slightly above your level. Use CP-31, Codeforces Problemset filters, and A2OJ ladders.

> **Upsolving is Everything**
>
> Every problem you couldn't solve in contest is a lesson. Upsolve within 24 hours or you wasted the contest.

> **Speed + Accuracy**
>
> In ICPC, more problems solved always wins. But when tied, lower penalty time breaks it—so speed matters.

***

## The Strategic Approach

### The "See the Pattern" Framework

When you read a problem, run through this mental checklist:

**1. Constraints Analysis (30 seconds)**

* n ≤ 20 → Bitmask DP / Brute force
* n ≤ 10³ → O(n²) solutions
* n ≤ 10⁵ → O(n log n) or O(n)
* n ≤ 10⁶ → O(n) only

**2. Problem Type Recognition (1 minute)**

* "Minimum/Maximum" → DP, Greedy, or Binary Search on Answer
* "Count ways" → DP or Combinatorics
* "Yes/No possible" → Greedy, Graph connectivity, or Binary Search
* "Shortest path" → BFS/Dijkstra
* "Subarray/Substring" → Two Pointers, Sliding Window, or Prefix Sum

**3. Pattern Matching (2-3 minutes)**

Match to known patterns. If stuck, think: "What's the simplest version of this problem I can solve?"

**4. Edge Cases (Before Coding)**

n=1, n=2, all same elements, all different, sorted, reverse sorted, negative numbers.

***

## What Makes This Course Different

> **Real CF Problems**
>
> Every topic has 10+ curated Codeforces problems with difficulty ratings.

> **Pattern Recognition**
>
> We teach you HOW to identify patterns, not just what the patterns are.

> **Common Mistakes**
>
> Every chapter covers the mistakes that cause WA/TLE so you avoid them.

> **Mental Models**
>
> Analogies and visualizations to build intuition, not just memorization.

> **CP-31 Integration**
>
> References to the famous CP-31 sheet for structured practice.

> **Contest Strategy**
>
> Not just algorithms—how to approach a 2-hour contest optimally.

***

## Course Structure: The Rating Ladder

### Phase 1: Foundation (Newbie → Pupil: 800-1200)

| Chapter | Topic | Key Patterns | Target Problems |
| - | - | - | - |
| 1 | Time Complexity | Constraint analysis | - |
| 2 | Fast I/O & Templates | Speed optimization | - |
| 3 | STL Mastery | Choosing right data structure | - |
| 4 | Prefix Sum | Range queries | CF 800-1100 |
| 5 | Two Pointers | Sorted arrays, subarrays | CF 800-1200 |

### Phase 2: Core Techniques (Pupil → Specialist: 1200-1400)

| Chapter | Topic | Key Patterns | Target Problems |
| - | - | - | - |
| 6 | Binary Search | Search on answer, bounds | CF 1100-1400 |
| 7 | Sorting Strategies | Custom comparators | CF 1100-1300 |
| 8 | Recursion & Backtracking | Subsets, permutations | CF 1200-1400 |
| 9 | Greedy Algorithms | Exchange arguments | CF 1200-1500 |
| 10 | Divide & Conquer | Merge sort pattern | CF 1300-1500 |

### Phase 3: Dynamic Programming (Specialist → Expert: 1400-1600)

| Chapter | Topic | Key Patterns | Target Problems |
| - | - | - | - |
| 11 | DP Fundamentals | 1D DP, state design | CF 1300-1600 |
| 12 | DP on Grids & Advanced | 2D DP, bitmask DP | CF 1400-1700 |

### Phase 4: Graphs (Expert Level: 1500-1700)

| Chapter | Topic | Key Patterns | Target Problems |
| - | - | - | - |
| 13 | Graph Fundamentals | DFS, BFS, cycles | CF 1300-1600 |
| 14 | Shortest Paths | Dijkstra, Floyd | CF 1400-1700 |
| 15 | Trees | LCA, tree DP | CF 1500-1800 |

### Phase 5: Advanced (Expert → Candidate Master: 1600-1900)

| Chapter | Topic | Key Patterns | Target Problems |
| - | - | - | - |
| 16 | Disjoint Set Union | Connectivity, MST | CF 1400-1700 |
| 17 | Segment Trees | Range queries with updates | CF 1500-1900 |
| 18 | String Algorithms | Hashing, KMP, Z-function | CF 1500-1800 |
| 19 | Bit Manipulation | XOR tricks, bitmask | CF 1400-1700 |
| 20 | Contest Strategy | ICPC & CF optimization | - |

***

## The CP-31 Integration

**CP-31** is a famous curated problem set that covers all essential topics. Throughout this course, we reference CP-31 problems that align with each chapter:

| CP-31 Topic | Our Chapter | Problems |
| - | - | - |
| Implementation | 1-3 | Foundation |
| Prefix Sums | 4 | Range queries |
| Two Pointers | 5 | Subarray problems |
| Binary Search | 6 | Search on answer |
| Greedy | 9 | Optimization |
| DP | 11-12 | All DP patterns |
| Graphs | 13-15 | Traversals, paths, trees |
| Data Structures | 16-17 | DSU, Segment Tree |
| Strings | 18 | Pattern matching |

***

## Practice Resources

> **[Codeforces](https://codeforces.com)**
>
> Primary platform. Filter problems by rating and tags. Participate in every contest.

> **[CSES Problem Set](https://cses.fi/problemset)**
>
> 300 classic problems. Perfect for pattern practice.

> **[AtCoder](https://atcoder.jp)**
>
> Clean problems. Great for math and DP.

> **[CP-31 Sheet](https://codeforces.com/blog/entry/55274)**
>
> Curated topic-wise problems for systematic practice.

### Essential Tools & Extensions

| Tool | Purpose | Link |
| - | - | - |
| **Competitive Companion** | Parse problems to IDE | [Chrome](https://chrome.google.com/webstore/detail/competitive-companion/cjnmckjndlpiamhfimnnjmnckgghkjbl) |
| **CF-Predictor** | Predict rating changes | [Chrome Extension](https://chrome.google.com/webstore/detail/cf-predictor/ocfloejljfognbljnlbjajgocmpgjppl) |
| **Carrot** | Rating predictor (alternate) | [Chrome](https://chrome.google.com/webstore/detail/carrot/gakohpplicjdhhfllilcjpfildodfnnn) |
| **CPH (VS Code)** | Auto testing in VS Code | [VS Code Extension](https://marketplace.visualstudio.com/items?itemName=DivyanshuAgrawal.competitive-programming-helper) |
| **A2OJ Ladders** | Rating-based problem lists | [A2OJ](https://a2oj.com/ladders) |
| **CF Visualizer** | Analyze your stats | [cfviz](https://cfviz.netlify.app/) |

### Recommended Problem Lists

> **CSES 300**
>
> Complete the entire CSES problemset. Covers all fundamentals.

> **Striver's CP Sheet**
>
> 450 curated problems for placement prep.

> **Junior Training Sheet**
>
> 500 problems from 800 to 1600 rating.

***

## The Mindset of Champions

> [!WARNING]
>
> **Reading ≠ Learning. Solving ≠ Understanding.**
>
> The only way to improve is:
>
> 1. **Struggle** with problems (at least 30-60 minutes before hints)
> 2. **Upsolve** everything you couldn't solve
> 3. **Analyze** why you got stuck
> 4. **Repeat** patterns until they're automatic

### Weekly Practice Schedule (Recommended)

| Day | Activity |
| - | - |
| Mon-Wed | Solve 3-5 problems/day from current topic |
| Thu | Virtual contest (past Div2) |
| Fri | Upsolve Thursday's contest |
| Sat | Live Codeforces contest |
| Sun | Upsolve + Review mistakes |

***

## Let's Begin Your Journey

> **[8-Week Roadmap to Specialist](https://resources.devweekends.com/courses/competitive-programming/01a-8-week-roadmap.md)**
>
> Structured weekly plan to go from LeetCode solver to CF Specialist (1400+).

> **[Codeforces Survival Guide](https://resources.devweekends.com/courses/competitive-programming/01b-cf-guide.md)**
>
> Everything LeetCode users need to know about CF—ratings, contests, I/O.

> **[Setup Your Environment](https://resources.devweekends.com/courses/competitive-programming/02a-environment-setup.md)**
>
> Configure VS Code, templates, and tools for competitive programming.

> **[Contest Strategy](https://resources.devweekends.com/courses/competitive-programming/20-contest-strategy.md)**
>
> Master the meta-skills that separate winners from participants.

### Quick Links

| Resource | Description |
| - | - |
| [Upsolving Guide](https://resources.devweekends.com/courses/competitive-programming/01c-upsolving.md) | How to learn from every problem |
| [Debugging Guide](https://resources.devweekends.com/courses/competitive-programming/01d-debugging.md) | Find bugs faster with systematic debugging |
| [CF Problem Types](https://resources.devweekends.com/courses/competitive-programming/01e-problem-types.md) | Recognize common CF problem patterns |
| [Code Library](https://resources.devweekends.com/courses/competitive-programming/21-code-library.md) | Ready-to-use algorithm implementations |
| [Quick Reference](https://resources.devweekends.com/courses/competitive-programming/22-quick-reference.md) | One-page cheat sheet for contests |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.