Accel Thinking

CP Weekly Challenges

CCC DSA Roadmap: Data Structures and Algorithms from Junior to Senior

A CCC DSA roadmap from Junior to Senior, covering simulation, strings, grids, counting, prefix sums, graph search, greedy, DSU, shortest paths, dynamic programming, and typical historical CCC problems.

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

What to Study Next

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:

  1. What complexity does the input size allow?
  2. What structure is the problem really about?
  3. 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 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.

  1. Simulation and edge cases
  2. Strings and parsing
  3. Arrays, lists, and grids
  4. Frequency counting, sets, parity
  5. Prefix sums and sliding window
  6. Sorting and greedy reasoning
  7. DFS/BFS, flood fill, graph representation
  8. Binary search on answer
  9. DSU and MST
  10. Dijkstra and state graphs
  11. Dynamic programming
  12. 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

  1. Practicing only by year instead of by DSA pattern.
  2. Reading solutions without rewriting the code.
  3. Knowing BFS but failing to recognize graph models.
  4. Learning DP as a template instead of defining state and transition.
  5. Ignoring constraints and choosing the wrong complexity.
  6. Treating all wrong answers the same instead of classifying the error.

Review Questions

  1. What DSA patterns appear most often in Junior J4/J5?
  2. Why can many grid problems become graph search problems?
  3. What is the difference between prefix sum and sliding window?
  4. When should DSU come to mind?
  5. What are the three core questions in dynamic programming?
  6. If N = 500000 , which algorithmic approaches should you rule out first?