
CP Weekly Challenge
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.
CP Weekly Challenge
CCC DSA 知识地图:从 Junior 到 Senior 要掌握哪些数据结构与算法
从 Junior 到 Senior 梳理 CCC 常见 DSA 模型:simulation、字符串、grid、counting、prefix sum、graph search、greedy、DSU、最短路和 DP。
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?
准备 CCC 时,很多学生会问:“我到底要学哪些算法?”答案不是背一张很长的 DSA 清单,而是理解不同题型背后的模型:什么时候是 simulation,什么时候是 graph search,什么时候需要 prefix sum、greedy、DSU 或 dynamic programming。
这篇文章把 CCC Junior 到 Senior 常见的数据结构与算法整理成一张路线图。它适合学生用来查漏补缺,也适合家长理解:从 J1/J2 的基础实现,到 J4/J5 的建模,再到 S3/S4 的算法选择,能力是怎样一层一层长出来的。
本题在 CCC DSA 地图里的位置
- 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: 把零散的 CCC 真题整理成可复习的 DSA 学习路径。
- Where it appears again: CP Weekly 真题题解、Python/C++ Notes、CCC 赛前复习计划
下一步推荐
如果你正在规划 CCC 学习路径,可以配合下面这些文章阅读:
- 相关 CP Weekly 真题:CCC 2026 J4 Snail Path、CCC 2024 J5 Harvest Waterloo、CCC 2020 J5/S2 Escape Room、CCC 2017 S1 Sum Game
- 相关 Python / C++ 基础:loops、strings、lists/vectors、dictionaries/maps、sets、2D arrays、functions、debugging
- 相关 DSA 专题:CCC Grid Problems、CCC Counting Patterns、CCC Prefix and Sliding Window Patterns、CCC Senior Graph Toolkit、CCC Dynamic Programming Roadmap
这张地图应该怎么读
CCC 的 DSA 学习顺序大致可以分成三层:
| Stage | 目标 | 常见题位 |
|---|---|---|
| Foundation | 读懂题、写对基础模拟、处理输入输出和边界 | Junior J1-J3, Senior S1 |
| Modeling | 把题目转成数组、字符串、grid、graph 或 state | Junior J4-J5, Senior S1-S2 |
| Algorithm Selection | 根据 constraints 选择合适的算法模式 | Senior S3-S4 |
真正重要的不是“我学过多少算法名词”,而是看到题目后能回答三个问题:
- 输入规模暗示什么复杂度?
- 题目对象应该建模成什么结构?
- 我需要保存哪些状态,才能避免重复工作?
Junior 基础层:先把实现能力打稳
Junior 前半部分常考直接实现,但它不是“简单语法题”。它在训练学生把文字条件翻译成代码步骤。
| DSA 点 | 概要 | 典型历史考题 |
|---|---|---|
| 条件判断与分类 | 根据坐标、分数、规则输出不同结果 | CCC 2017 J1 Quadrant Selection, CCC 2024 J1 Conveyor Belt Sushi |
| 循环与累加 | 逐项处理输入,维护 total、count、best | CCC 2017 J2 Shifty Sum, CCC 2025 J2 Donut Shop |
| Simulation | 按题意一步一步更新状态 | CCC 2016 J4 Arrival Time, CCC 2026 J4 Snail Path |
| Edge cases | 处理 0、边界、全相同、刚好相等 | CCC 2017 J3 Exactly Electrical, CCC 2017 S1 Sum Game |
这一层最容易被低估。很多 J4/J5 的错误,不是算法不会,而是状态更新顺序、边界、输入解析不稳。
字符串与解析:把 text 当成结构化数据
CCC Junior 很喜欢把字符串当成轻量数据结构。学生需要会扫描、切片、计数、比较和解析数字。
| DSA 点 | 概要 | 典型历史考题 |
|---|---|---|
| 字符串遍历 | 一个字符一个字符扫描并更新状态 | CCC 2019 J3 Cold Compress, CCC 2025 J3 Product Codes |
| Substring / rotation | 判断某段字符串是否出现或循环移动 | CCC 2020 J4 Cyclic Shifts |
| Palindrome / pattern | 枚举或检查字符串结构 | CCC 2016 J3 Hidden Palindrome |
| Two pointers 入门 | 用两个位置描述当前检查范围 | CCC 2024 J4 Troublesome Keys, CCC 2025 J4 Sunny Days |
这一类题的核心不是写很多代码,而是先把“字符串里的信息”拆出来。比如 Product Codes 不是简单读字符,而是扫描字母段和数字段;Cold Compress 不是压缩算法模板,而是连续段计数。
Arrays、Lists 与 Grid:从一维状态到二维状态
当题目开始出现每天、每个位置、每个格子时,学生就需要用数组或 grid 保存状态。
| DSA 点 | 概要 | 典型历史考题 |
|---|---|---|
| 一维数组遍历 | 扫描列表,维护最大值、最小值、差值或累计值 | CCC 2021 S1 Crazy Fencing, CCC 2017 S1 Sum Game |
| 数组变换 | 对数组或矩阵做旋转、翻转、重排 | CCC 2019 J4 Flipper, CCC 2018 J4 Sunflowers |
| Grid coordinates | 用 (r, c) 或 (x, y) 表示位置 |
CCC 2026 J4 Snail Path, CCC 2023 J4/S1 Trianglane |
| Grid adjacency | 判断上下左右相邻、边界、周长 | CCC 2023 J4/S1 Trianglane |
Grid 题是 Junior 到 Senior 的重要桥梁。刚开始是“在格子里模拟”,后来会变成“把每个格子看成 graph node”。
Counting:frequency、set 与 parity
很多 CCC 题表面上像模拟,实际上只需要统计信息。学会 counting 后,学生会第一次明显感受到:好的数据结构可以让代码少很多。
| DSA 点 | 概要 | 典型历史考题 |
|---|---|---|
| Frequency counting | 统计每个值出现多少次 | CCC 2016 S1 Ragaman, CCC 2024 J3 Bronze Count |
| Set membership | 快速判断是否出现过、是否违反限制 | CCC 2022 J4/S2 Good Groups |
| Pair counting | 用频率数组统计组合 | CCC 2017 J5/S3 Nailed It! |
| Parity | 只关心奇偶,不关心具体次数 | CCC 2021 J5/S2 Modern Art |
Modern Art 是典型例子:如果真的维护整张画布,题目会变得又慢又复杂;如果只维护每一行和每一列是否被 toggle 奇数次,答案就变成公式。
Prefix Sum、Difference Array 与 Sliding Window
当题目要求反复查询区间、连续段、累计状态时,就进入 prefix thinking。
| DSA 点 | 概要 | 典型历史考题 |
|---|---|---|
| Running prefix sum | 只维护当前累计值 | CCC 2017 S1 Sum Game |
| Prefix arrays | 预处理前缀,快速回答区间问题 | CCC 2020 S4 Swapping Seats |
| Difference array | 对多个区间更新做压缩 | CCC 2026 J5/S2 Beams of Light |
| Sliding window | 维护一个满足条件的连续窗口 | CCC 2020 S3 Searching for Strings, CCC 2025 J4 Sunny Days |
| Center expansion | 从中心向外扩展比较状态 | CCC 2023 S2 Symmetric Mountains |
Sunny Days 可以看作 prefix/suffix consecutive counts,也可以看作 sliding window with one correction。它很适合作为 Junior 学生第一次接触“窗口状态维护”的例子。
Sorting 与 Greedy:先排序,再做局部选择
Greedy 题不只是“看起来顺手就这样做”。真正的重点是:为什么这个局部选择不会破坏最优答案?
| DSA 点 | 概要 | 典型历史考题 |
|---|---|---|
| Sorting | 先把数据排成容易比较的顺序 | CCC 2016 J5/S2 Tandem Bicycle |
| Greedy selection | 每次选择当前最合适的元素 | CCC 2013 J4 Time on Task |
| Greedy assignment | 把资源分配给能接受它的最大/最小位置 | CCC 2015 S3 Gates |
| Greedy construction | 构造一个满足条件的输出 | CCC 2017 S2 High Tide, Low Tide |
Tandem Bicycle 是 Junior/Senior 之间很好的例子:排序后配对,最大速度或最小速度的策略就清楚了。Gates 则进一步引出 DSU,因为每次找可用 gate 不能线性扫描。
Graph Search:从 grid 到 graph
很多学生第一次听到 graph 会觉得抽象。其实在 CCC 中,graph 通常来自三种东西:grid 相邻关系、页面/节点连接关系、状态转移关系。
| DSA 点 | 概要 | 典型历史考题 |
|---|---|---|
| DFS / BFS reachability | 判断能不能从 A 到 B | CCC 2018 J5 Choose Your Own Adventure, CCC 2013 S4 Who is Taller |
| Flood fill | 找出从起点可达的一整片区域 | CCC 2024 J5 Harvest Waterloo |
| Grid BFS | 在 grid 上做最短路或可达性 | CCC 2018 S3 RoboThieves |
| Implicit graph | 边不直接给出,需要由规则生成 | CCC 2020 J5/S2 Escape Room |
| Multi-source BFS | 从多个起点同时扩散 | Senior grid graph topics |
Escape Room 是很好的桥梁题。它不是四方向走 grid,而是从格子里的数字跳到满足乘积关系的位置。学生会看到:graph 不一定是题目直接给的,有时要自己建模。
Binary Search on Answer
Senior S3/S4 经常出现一种题型:答案本身不是直接算出来的,但可以猜一个答案,再判断它是否可行。
| DSA 点 | 概要 | 典型历史考题 |
|---|---|---|
| Binary search | 在有序范围中查找目标 | 基础语言与数组训练 |
| Binary search on answer | 猜答案,再写 feasibility check | CCC 2010 S3 Firehose |
| Convex / unimodal reasoning | 根据代价函数结构寻找最优点 | CCC 2021 S3 Lunch Concert |
这类题的关键是把问题拆成两层:
Can we do it with answer = X?
如果 X 可行,更大的或更小的范围也有明确方向,就可以 binary search。
DSU 与 MST:维护连通性
Disjoint Set Union 是 Senior 图论中非常常见的数据结构。它擅长回答:“两个点是否已经在同一个连通块里?”以及“合并两个连通块”。
| DSA 点 | 概要 | 典型历史考题 |
|---|---|---|
| DSU find/union | 快速维护连通块 | CCC 2015 S3 Gates |
| Kruskal MST | 按边权排序,逐步连接组件 | CCC 2010 S4 Animal Farm |
| MST-style processing | 分组边、判断连通性、处理成本 | CCC 2023 S4 Minimum Cost Roads |
| Partial scoring strategy | 先写能拿部分分的模型 | CCC 2017 S4 Minimum Cost Flow |
DSU 的难点不是代码很长,而是识别场景:当题目不断合并关系、检查可用位置或建立最小连接结构时,就应该想到 components。
Weighted Shortest Paths 与 State Graph
当边有不同代价,普通 BFS 就不够了。Senior S4 常常要求 Dijkstra,甚至要求把状态扩展成 (node, extra_state)。
| DSA 点 | 概要 | 典型历史考题 |
|---|---|---|
| Dijkstra | 边权非负的最短路 | CCC 2009 S4 Shop and Ship |
| Expanded state graph | 节点不只是位置,还包含额外状态 | CCC 2015 S4 Convex Hull, CCC 2025 S4 Floor Is Lava |
| 0-1 BFS | 边权只有 0 和 1 的特殊最短路 | Senior grid graph topics |
State graph 是 Senior 难点之一。学生要学会问:如果只用位置做 node,信息够不够?如果不够,就把额外条件加入 state。
Dynamic Programming:state、transition、order
DP 是 CCC Senior 的核心之一,但不要一上来背模板。先问三个问题:
state表示什么?transition从哪里来?- 计算顺序如何保证依赖已经完成?
| DSA 点 | 概要 | 典型历史考题 |
|---|---|---|
| Memoization | 递归搜索中保存结果 | CCC 2015 J5 Pi Day |
| Grid DP | 从相邻位置转移 | CCC 2025 J5 Connecting Territories, CCC 2012 S5 Mouse Journey |
| DAG DP | 按依赖方向累计答案 | CCC 2007 S4 Waterpark |
| Interval DP | 对区间长度从小到大转移 | CCC 2016 S4 Combining Riceballs |
| Rolling array | 只保留必要层,降低空间 | CCC 2025 J5 Connecting Territories |
Connecting Territories 是很好的 DP 入门题:每一行只依赖上一行,所以可以用 rolling array。Combining Riceballs 则进入更典型的 interval DP。
Constructive、Constraint Propagation 与 Search
有些 Senior 题不是标准 graph 或 DP,而是需要先分析限制,再构造答案或缩小搜索空间。
| DSA 点 | 概要 | 典型历史考题 |
|---|---|---|
| Brute force with pruning | 枚举可行状态,但及时剪枝 | CCC 2013 J5 Chances of Winning |
| State-space search | 把每个局面当成 state | CCC 2015 J5 Rule of Three |
| Constraint propagation | 根据限制逐步推导未知量 | CCC 2019 S3 Arithmetic Square |
| Constructive algorithms | 直接构造满足条件的答案 | CCC 2023 S3 Palindromic Poster, CCC 2024 S3 Swipe |
这一类题很考“读题后的第一步”。如果直接写代码,很容易陷入复杂分支;如果先找约束,题目往往会变清楚。
一条推荐学习路线
如果学生从 Junior 走向 Senior,可以按这个顺序复习:
- 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
这个顺序不是绝对的。更实际的做法是:每学一个知识点,就配 2-4 道历史题。先看一个讲解,再独立做一道相似题,最后复盘错因。
常见误区
- 只按年份刷题,不按 DSA 模型复盘。
- 只看懂题解,不重写代码。
- 学了 BFS,但不知道什么时候题目其实是 graph。
- 学了 DP,但每道题都想套同一个模板。
- 忽略 constraints,导致算法复杂度选错。
- 不总结错题类型:读题错、边界错、状态定义错、复杂度错,是完全不同的问题。
复习问题
- Junior J4/J5 最常见的 DSA 模型有哪些?
- 为什么 grid 题经常可以转成 graph search?
- Prefix sum 和 sliding window 的区别是什么?
- 什么情况下应该想到 DSU?
- Dynamic programming 的三个核心问题是什么?
- 如果一道题的输入规模是
N = 500000,你会首先排除哪些算法?
Questions or feedback?
Have a question about this article or want to suggest an improvement? Send us a private message.
有问题或建议?
如果你对本文有疑问,或希望提出改进建议,请给我们发送私密留言。
Related Learning
Continue exploring related learning paths.
These related pages help students and parents move from interest to the right next step.