A structured competitive programming knowledge base focused on algorithmic thinking, data structures, and high-performance C++ implementations.
Install
npx skillscat add area44/cp-skills/cp-skills-cpp Install via the SkillsCat registry.
SKILL.md
Competitive Programming Skills
A structured and efficiency-driven knowledge base for mastering competitive programming. This repository emphasizes algorithmic reasoning, core data structures, implementation patterns, and writing optimized C++23 code under contest constraints.
Objectives
- Develop strong algorithmic intuition.
- Build clean and minimal implementation habits.
- Maintain high-performance coding discipline.
- Improve speed and accuracy under time pressure.
Language & Coding Standards
Language Standard
- Use C++23.
Code Style Guidelines
Minimalism First
- Do not include comments in final submission code.
- Avoid unnecessary abstractions.
- Do not create a
solve()function if the logic fits clearly insidemain().
- Do not create a
- Avoid unnecessary variables.
- Do not store intermediate results if they are used only once.
Naming & Structure Guidelines
Variables
- Use
camelCase. - Keep names simple, clear, and descriptive.
Functions
- Use
snake_case. - Function names must begin with a verb.
- Clearly describe the action performed.
Constants
- Use
ALL_CAPSwith underscores.
Code Structure
- Keep logic linear and readable.
- Avoid deep nesting when possible.
- Prefer early returns to reduce indentation.
- Minimize global variables (allowed only for constants and large shared arrays).
Loop Preferences
- Prefer range-based loops.
- Use
for (auto &x : container)when modifying elements or avoiding copies. - Use
for (auto x : container)for read-only access.
- Use
STL Discipline
- Prefer
vectoroverarray. - Prefer
vectoroversetormapunless ordering or logarithmic operations are required. - Prefer
sort()over maintaining dynamically ordered containers. - Avoid
multisetunless strictly necessary. - Use
reserve()when size is known in advance. - Prefer
emplace_back()for in-place construction. - Avoid unnecessary copying of large structures.
- Prefer
const vector<int>&overvector<int>when passing arguments.
- Prefer
I/O Rules
- Use
cinandcout. - Disable synchronization:
ios::sync_with_stdio(false);
cin.tie(nullptr);- Use
"\n"instead ofendl.
Performance Discipline
- Estimate time complexity before coding.
- Target complexity guidelines:
O(n)orO(n log n)forn ≤ 2e5O(n^2)only ifn ≤ 2000O(2^n)only ifn ≤ 20
- Preallocate memory when possible.
- Avoid resizing containers inside loops.
- Use static arrays when size is fixed and performance-critical.
Compilation Template
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using i128 = __int128_t;
constexpr ll INF = LLONG_MAX;
constexpr int MOD = 998244353;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
return 0;
}Competitive Programming Philosophy
Competitive programming requires:
- Careful constraint analysis.
- Strong pattern recognition.
- Transforming brute force into structured logic.
- Writing correct code quickly under pressure.
Clarity over cleverness. Performance over abstraction. Correctness over style.
Build intuition. Remove noise. Optimize thinking.