When students prepare for the CCC, they often ask: “Which algorithms do I need to know?” The useful answer is not a giant list of DSA names. The useful answer is a roadmap of patterns: simulation, strings, arrays, grids, counting, prefix sums, graph search, greedy, DSU, shortest paths, and dynamic programming.
This article organizes the common CCC data structures and algorithms from Junior to Senior. It is designed as a study map for students and as a parent-friendly overview of how contest programming grows from careful implementation into algorithmic modeling.
Where This Fits in the CCC DSA Map
- Level: Junior to Senior roadmap
- Pattern: DSA planning, pattern recognition, contest preparation
- Prerequisite: Python/C++ basics, arrays/lists, loops, strings, functions, debugging
- What this teaches: Organize CCC problems into a reusable study path instead of treating each problem as isolated.
- Where it appears again: CP Weekly solutions, Python/C++ Notes, CCC contest review plans
What to Study Next
- Related CP Weekly problems: CCC 2026 J4 Snail Path , CCC 2024 J5 Harvest Waterloo , CCC 2020 J5/S2 Escape Room , CCC 2017 S1 Sum Game
- Related Python / C++ foundations: loops, strings, lists/vectors, dictionaries/maps, sets, 2D arrays, functions, debugging
- Related DSA roadmap articles: CCC Grid Problems, CCC Counting Patterns, CCC Prefix and Sliding Window Patterns, CCC Senior Graph Toolkit, CCC Dynamic Programming Roadmap
How to Read This Roadmap
CCC preparation has three layers:
| Stage | Goal | Common contest range |
|---|---|---|
| Foundation | Read carefully, implement simulation, handle input/output and edge cases | Junior J1-J3, Senior S1 |
| Modeling | Turn the problem into arrays, strings, grids, graphs, or states | Junior J4-J5, Senior S1-S2 |
| Algorithm Selection | Use constraints to choose the right pattern | Senior S3-S4 |
The key is to ask:
- What complexity does the input size allow?
- What structure is the problem really about?
- What state should I store so I do not repeat work?
Foundation: Implementation Before Fancy Algorithms
Junior problems train careful implementation. This stage includes conditionals, loops, accumulation, simulation, and edge cases.
| DSA idea | Summary | Typical CCC problems |
|---|---|---|
| Condition tables | Choose output based on signs, scores, or rules | CCC 2017 J1 Quadrant Selection, CCC 2024 J1 Conveyor Belt Sushi |
| Loops and accumulation | Maintain totals, counts, and best values | CCC 2017 J2 Shifty Sum, CCC 2025 J2 Donut Shop |
| Simulation | Update state exactly as the story says | CCC 2016 J4 Arrival Time, CCC 2026 J4 Snail Path |
| Edge cases | Handle zero, boundaries, all-same input, exact equality | CCC 2017 J3 Exactly Electrical, CCC 2017 S1 Sum Game |
Many later mistakes come from this layer: wrong update order, missing boundary cases, or misunderstood input.
Strings and Parsing
CCC often uses strings as lightweight data structures. Students need to scan, slice, count, compare, and parse.
| DSA idea | Summary | Typical CCC problems |
|---|---|---|
| String traversal | Scan characters and update state | CCC 2019 J3 Cold Compress, CCC 2025 J3 Product Codes |
| Substrings and rotations | Check whether a shifted or sliced pattern appears | CCC 2020 J4 Cyclic Shifts |
| Palindrome and pattern checks | Enumerate or verify string structure | CCC 2016 J3 Hidden Palindrome |
| Two-pointer basics | Use two positions to track a range or mismatch | CCC 2024 J4 Troublesome Keys, CCC 2025 J4 Sunny Days |
The goal is to extract structure from text before writing loops.
Arrays, Lists, and Grids
Once the problem has days, positions, scores, or cells, students need arrays and grids.
| DSA idea | Summary | Typical CCC problems |
|---|---|---|
| Array traversal | Scan values and maintain totals or extremes | CCC 2021 S1 Crazy Fencing, CCC 2017 S1 Sum Game |
| Array transformation | Rotate, flip, or rearrange stored state | CCC 2019 J4 Flipper, CCC 2018 J4 Sunflowers |
| Grid coordinates | Represent positions with (r, c) or (x, y) |
CCC 2026 J4 Snail Path, CCC 2023 J4/S1 Trianglane |
| Grid adjacency | Reason about neighbors, boundaries, and perimeter | CCC 2023 J4/S1 Trianglane |
Grid problems are a major bridge from Junior to Senior because a grid can become a graph.
Counting: Frequency, Sets, and Parity
Counting is often the first moment when students see the value of a data structure.
| DSA idea | Summary | Typical CCC problems |
|---|---|---|
| Frequency counting | Count how often each value appears | CCC 2016 S1 Ragaman, CCC 2024 J3 Bronze Count |
| Sets | Check membership and constraints quickly | CCC 2022 J4/S2 Good Groups |
| Pair counting | Count combinations with frequency arrays | CCC 2017 J5/S3 Nailed It! |
| Parity | Track odd/even instead of exact counts | CCC 2021 J5/S2 Modern Art |
Modern Art is the classic example: the full grid is unnecessary if we track row and column parity.
Prefix Sum and Sliding Window
Prefix thinking appears when a problem involves repeated ranges, consecutive segments, or cumulative state.
| DSA idea | Summary | Typical CCC problems |
|---|---|---|
| Running prefix sum | Keep only the current cumulative value | CCC 2017 S1 Sum Game |
| Prefix arrays | Precompute sums for fast range queries | CCC 2020 S4 Swapping Seats |
| Difference array | Compress many interval updates | CCC 2026 J5/S2 Beams of Light |
| Sliding window | Maintain a valid consecutive window | CCC 2020 S3 Searching for Strings, CCC 2025 J4 Sunny Days |
| Center expansion | Expand from a center and compare states | CCC 2023 S2 Symmetric Mountains |
Sunny Days is a good transition problem: it can be explained with prefix/suffix streaks or as a sliding window with one correction.
Sorting and Greedy
Greedy problems are not just “do the obvious thing.” Students must learn why a local choice is safe.
| DSA idea | Summary | Typical CCC problems |
|---|---|---|
| Sorting | Put data into an order that makes comparison easy | CCC 2016 J5/S2 Tandem Bicycle |
| Greedy selection | Choose the best current option | CCC 2013 J4 Time on Task |
| Greedy assignment | Assign resources to compatible positions | CCC 2015 S3 Gates |
| Greedy construction | Build an output that satisfies the rule | CCC 2017 S2 High Tide, Low Tide |
Gates also leads naturally to DSU because repeatedly searching for an available gate is too slow.
Graph Search
Graph problems often come from grids, pages, relationships, or state transitions.
| DSA idea | Summary | Typical CCC problems |
|---|---|---|
| DFS/BFS reachability | Decide whether one node can reach another | CCC 2018 J5 Choose Your Own Adventure, CCC 2013 S4 Who is Taller |
| Flood fill | Visit an entire reachable region | CCC 2024 J5 Harvest Waterloo |
| Grid BFS | Search a grid with movement rules or hazards | CCC 2018 S3 RoboThieves |
| Implicit graph | Generate edges from the rule instead of reading them directly | CCC 2020 J5/S2 Escape Room |
| Multi-source BFS | Start search from multiple sources at once | Senior grid graph topics |
Escape Room is a strong bridge problem: the graph is not given directly, but the rule creates edges.
Binary Search on Answer
Some Senior problems ask for an optimal value that is hard to compute directly but easy to test.
| DSA idea | Summary | Typical CCC problems |
|---|---|---|
| Binary search | Search inside an ordered range | Foundation array practice |
| Binary search on answer | Guess an answer, then check feasibility | CCC 2010 S3 Firehose |
| Convex or unimodal reasoning | Use cost structure to locate an optimum | CCC 2021 S3 Lunch Concert |
The key question is:
Can we do it with answer = X?
If feasibility is monotonic, binary search becomes available.
DSU and MST
Disjoint Set Union maintains connected components under merges.
| DSA idea | Summary | Typical CCC problems |
|---|---|---|
| DSU find/union | Maintain components efficiently | CCC 2015 S3 Gates |
| Kruskal MST | Sort edges and connect components | CCC 2010 S4 Animal Farm |
| MST-style processing | Group edges and reason about connection cost | CCC 2023 S4 Minimum Cost Roads |
| Partial scoring strategy | Build simpler correct versions first | CCC 2017 S4 Minimum Cost Flow |
Think of DSU when the problem repeatedly merges things or asks whether two items are already connected.
Weighted Shortest Paths and State Graphs
When edges have different costs, plain BFS is not enough.
| DSA idea | Summary | Typical CCC problems |
|---|---|---|
| Dijkstra | Shortest path with nonnegative edge weights | CCC 2009 S4 Shop and Ship |
| Expanded state graph | Include extra information inside the node state | CCC 2015 S4 Convex Hull, CCC 2025 S4 Floor Is Lava |
| 0-1 BFS | Special shortest path when edge weights are 0 or 1 | Senior grid graph topics |
The key modeling question is: does position alone describe the state, or do we need extra information such as damage, mode, or remaining resource?
Dynamic Programming
Dynamic programming is about state, transition, and order.
| DSA idea | Summary | Typical CCC problems |
|---|---|---|
| Memoization | Store recursive search results | CCC 2015 J5 Pi Day |
| Grid DP | Transition from neighboring positions | CCC 2025 J5 Connecting Territories, CCC 2012 S5 Mouse Journey |
| DAG DP | Accumulate answers along directed dependencies | CCC 2007 S4 Waterpark |
| Interval DP | Solve smaller intervals before larger ones | CCC 2016 S4 Combining Riceballs |
| Rolling array | Keep only the previous layer when possible | CCC 2025 J5 Connecting Territories |
Connecting Territories is a good first DP example because each row only depends on the previous row.
Constructive Search and Constraint Propagation
Some Senior problems require analyzing constraints before writing code.
| DSA idea | Summary | Typical CCC problems |
|---|---|---|
| Brute force with pruning | Enumerate states but stop impossible branches | CCC 2013 J5 Chances of Winning |
| State-space search | Treat each configuration as a state | CCC 2015 J5 Rule of Three |
| Constraint propagation | Use restrictions to infer missing values | CCC 2019 S3 Arithmetic Square |
| Constructive algorithms | Directly build a valid answer | CCC 2023 S3 Palindromic Poster, CCC 2024 S3 Swipe |
These problems reward thinking before coding. The first step is often to reduce the search space.
Recommended Study Order
- Simulation and edge cases
- Strings and parsing
- Arrays, lists, and grids
- Frequency counting, sets, parity
- Prefix sums and sliding window
- Sorting and greedy reasoning
- DFS/BFS, flood fill, graph representation
- Binary search on answer
- DSU and MST
- Dijkstra and state graphs
- Dynamic programming
- Constructive search and constraint propagation
For each topic, pair one explanation with two to four historical problems. Then review mistakes by type: reading error, edge case, state definition, implementation bug, or complexity mismatch.
Common Mistakes
- Practicing only by year instead of by DSA pattern.
- Reading solutions without rewriting the code.
- Knowing BFS but failing to recognize graph models.
- Learning DP as a template instead of defining state and transition.
- Ignoring constraints and choosing the wrong complexity.
- Treating all wrong answers the same instead of classifying the error.
Review Questions
- What DSA patterns appear most often in Junior J4/J5?
- Why can many grid problems become graph search problems?
- What is the difference between prefix sum and sliding window?
- When should DSU come to mind?
- What are the three core questions in dynamic programming?
- If
N = 500000, which algorithmic approaches should you rule out first?
Questions or feedback?
Have a question about this article or want to suggest an improvement? Send us an email.
