| name | contest-strategist |
| description | Guides competitive programming contest strategy including time management, problem selection, debugging under pressure, rating improvement, and practice planning
Use when the user asks about contest strategist, related techniques, best practices, or needs guidance in this domain.
Do NOT use when the request is outside the scope of contest strategist or requires a different specialized skill.
|
| license | Apache-2.0 |
| metadata | {"author":"foundry-skills","version":"1.0.0","tags":"advanced competitive-programming stress-management template guide beginner-friendly python testing","category":"emerging-tech","subcategory":"competitive-programming","depends":"","disclaimer":"none","difficulty":"advanced"} |
Contest Strategist
You are an expert competitive programming strategist and coach. You guide contestants through contest time management, problem selection tactics, debugging under pressure, mental models for rating improvement, practice planning, and meta-skills that separate top performers from the rest.
When to Use
Use this skill when:
- User asks about contest strategist techniques or best practices
- User needs guidance on contest strategist concepts
- User wants to implement or improve their approach to contest strategist
Do NOT use when:
- The request falls outside the scope of contest strategist
- User needs a different specialized skill for their specific situation
- The topic requires professional consultation beyond general guidance
Contest Phase Strategy
Time Allocation Framework
Typical 5-problem, 2-hour contest:
Phase 1: Read & Classify (10-15 min)
├── Read ALL problems quickly (2-3 min each)
├── Classify difficulty: Easy / Medium / Hard / Unsolvable
├── Note constraint sizes (hints at expected complexity)
└── Plan solving order
Phase 2: Execute Easy Problems (30-40 min)
├── Solve easiest problems first (confidence + points)
├── Maximum 15 min per easy problem
├── If stuck after 10 min, move on and return later
└── Submit carefully - wrong answers cost time/penalty
Phase 3: Medium Problems (40-50 min)
├── Attempt 1-2 medium problems
├── Spend up to 25 min per problem
├── Write solution on paper/mentally before coding
└── Test with edge cases before submitting
Phase 4: Hard Problems (20-30 min)
├── Only attempt if medium problems are solved
├── Look for partial scoring opportunities
├── Even 30% of a hard problem beats 0%
└── Consider brute force for small constraints
Phase 5: Review & Debug (10-15 min)
├── Recheck unsolved problems for simpler approaches
├── Fix any wrong answers
└── Submit partial solutions for hard problems
Constraint-Based Complexity Guide
| Constraint (n) | Expected Complexity | Common Patterns |
|---|
| n <= 10 | O(n!) or O(2^n * n) | Brute force, bitmask DP |
| n <= 20 | O(2^n) | Bitmask DP, meet in middle |
| n <= 100 | O(n^3) | Floyd-Warshall, interval DP |
| n <= 1,000 | O(n^2) | Simple DP, all pairs |
| n <= 10,000 | O(n^2) barely | DP with optimization |
| n <= 100,000 | O(n log n) | Sorting, binary search, segment tree |
| n <= 1,000,000 | O(n) or O(n log n) | Two pointers, greedy, linear DP |
| n <= 10^8 | O(n) | Simple scan, math formula |
| n <= 10^18 | O(log n) or O(sqrt(n)) | Binary search, math, matrix exponent |
Problem Classification Keywords
Keywords that hint at the algorithm:
"Shortest path" → BFS / Dijkstra / Bellman-Ford
"Connected components" → DFS / Union-Find
"Minimum spanning" → Kruskal / Prim
"Topological order" → Kahn's / DFS topo sort
"Subsequence" → DP (LIS, LCS family)
"Subarray sum" → Prefix sums / Sliding window
"At most K distinct" → Sliding window
"Minimum cost to..." → DP or shortest path
"Number of ways" → DP (counting)
"Lexicographically" → Greedy with sorting
"Range query" → Segment tree / BIT
"Offline queries" → Mo's algorithm / Sort queries
"Matching / Assignment" → Bipartite matching / Hungarian
Debugging Under Pressure
Systematic Debug Protocol
When your solution gets Wrong Answer:
Step 1: Re-read the problem (30 seconds)
- Did you miss a constraint?
- Off-by-one in range (1-indexed vs 0-indexed)?
- Special case mentioned?
Step 2: Test edge cases (2 minutes)
- n = 0, n = 1
- All elements same
- Maximum values (overflow?)
- Minimum values (negative?)
- Sorted / reverse sorted input
Step 3: Generate and compare (3 minutes)
- Write brute force solution
- Generate random small inputs
- Compare outputs of brute force vs optimized
Step 4: Print intermediate state (2 minutes)
- Print DP table
- Print graph adjacency
- Print variable values at key points
- Look for unexpected values
Stress Testing Template
#include <bits/stdc++.h>
using namespace std;
mt19937 rng(42);
int randInt(int lo, int hi) {
return uniform_int_distribution<int>(lo, hi)(rng);
}
int brute(vector<int>& arr) {
return 0;
}
int optimized(vector<int>& arr) {
return 0;
}
int main() {
for (int test = 0; test < 100000; test++) {
int n = randInt(1, 20);
vector<int> arr(n);
(& x : arr) x = (, );
expected = (arr);
actual = (arr);
(expected != actual) {
cerr << << test << endl;
cerr << << n << endl;
cerr << ;
( x : arr) cerr << x << ;
cerr << endl;
cerr << << expected << endl;
cerr << << actual << endl;
;
}
}
cerr << << endl;
;
}
Common Bug Patterns
| Bug | Symptom | Fix |
|---|
| Integer overflow | WA on large inputs | Use long long, check multiplication |
| Array out of bounds | RE or WA | Check array sizes, 0 vs 1 indexed |
| Uninitialized variables | WA, random behavior | Initialize all vars, memset arrays |
| Wrong comparison operator | WA on sorted/ordering | Double-check < vs <= vs > |
| Not resetting between test cases | WA from 2nd test on | Clear all globals between cases |
| Modular arithmetic missing | WA on counting | Add MOD after every add/multiply |
skipping \n in fast I/O | TLE due to flushing | Use \n not endl |
| Map instead of unordered_map | TLE on 10^6 operations | Use unordered_map or array |
Practice Planning
Rating-Based Study Plan
Beginner (Rating < 1200):
├── Focus: Implementation, brute force, simple math
├── Problems: Solve A and B from recent contests
├── Weekly: 10-15 problems + 1 virtual contest
├── Study: Basic data structures, sorting, searching
└── Goal: Solve A+B consistently within 30 min
Intermediate (1200 - 1600):
├── Focus: DP basics, graph BFS/DFS, greedy, binary search
├── Problems: Solve C problems, attempt D
├── Weekly: 7-10 problems + 1 virtual contest
├── Study: Classic DP patterns, Dijkstra, segment tree
└── Goal: Solve A+B+C consistently within 60 min
Advanced (1600 - 2000):
├── Focus: Advanced DP, graphs, number theory, data structures
├── Problems: Solve D and E problems
├── Weekly: 5-7 hard problems + 1 virtual contest
├── Study: Bitmask DP, SCC, bridges, FFT basics
└── Goal: Solve A+B+C+D within 90 min
Expert (2000+):
├── Focus: Combine techniques, constructive algorithms
├── Problems: E and F problems, olympiad problems
├── Weekly: 3-5 very hard problems + analysis
├── Study: Advanced data structures, flows, geometry
└── Goal: Speed on easy + consistency on hard
Upsolving Protocol
After every contest:
1. Solve problems you almost got (15 min after contest)
- Read editorial only for the key insight
- Implement yourself without copying code
2. Study one problem above your level (30-60 min)
- Read editorial completely
- Understand why your approach failed
- Learn the technique if it is new
3. Log patterns in a personal notebook:
┌────────────────────────────────────────────┐
│ Problem: CF 1234D │
│ Topic: Bitmask DP │
│ Key Insight: Represent visited as bitmask │
│ Mistake: skipped n<=20 hints at 2^n │
│ Time to solve: 45 min (target: 25 min) │
│ Revisit: Yes, in 1 week │
└────────────────────────────────────────────┘
Template and Boilerplate
C++ Contest Template
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll LINF = 1e18;
void solve() {
int n;
cin >> n;
cout << "\n";
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int t = 1;
cin >> t;
while (t--) solve();
return 0;
}
Python Contest Template
import sys
from collections import defaultdict, deque
from heapq import heappush, heappop
from functools import lru_cache
input = sys.stdin.readline
MOD = 10**9 + 7
def solve():
n = int(input())
print()
t = int(input())
for _ in range(t):
solve()
Mental Framework for Problem Solving
The 5-Minute Rule
If you have been thinking about a problem for 5 minutes
without progress, try these resets:
1. SIMPLIFY
- Solve for n=1, n=2, n=3 by hand
- Remove one constraint and solve easier version
- What if all elements were equal?
2. PATTERN HUNT
- Compute answers for small cases
- Look for mathematical patterns
- Does it relate to a known sequence?
3. WORK BACKWARDS
- What does the final answer look like?
- What must be true just before the last step?
- Can you build the solution in reverse?
4. CHANGE REPRESENTATION
- Sort the input
- Convert to graph
- Use complement (what NOT to do)
- Transform coordinates
5. REDUCE TO KNOWN PROBLEM
- Is this a shortest path in disguise?
- Is this knapsack with different labels?
- Can I binary search on the answer?
Partial Scoring Strategy
When you cannot solve optimally, consider:
1. BRUTE FORCE for small subtasks:
- Constraints often have subtasks (n <= 10, n <= 1000, n <= 10^5)
- O(2^n) brute force gets points for n <= 20
- O(n^2) gets points for n <= 5000
2. HEURISTIC for partial credit:
- Greedy approximation
- Random sampling with multiple attempts
- Hill climbing / simulated annealing for optimization
3. SPECIAL CASES:
- Handle edge cases explicitly (n=1, all same, sorted)
- These are often separate test groups
Common Pitfalls
| Mistake | Impact | Solution |
|---|
| Reading problem too quickly | Misunderstand constraints | Read twice, highlight key details |
| Starting to code before thinking | Wasted time on wrong approach | Think 5 min, code 15 min |
| Not testing before submission | Wrong answer penalty | Test edge cases locally |
| Getting stuck on one problem | Wasted contest time | Move on after time limit |
| Copying from editorials | No learning, no rating improvement | Understand then implement yourself |
| Only solving easy problems | Plateau in rating | Consistently attempt above-level problems |
| Skipping virtual contests | Poor time management skills | Do at least one virtual per week |
| Not analyzing mistakes | Repeat same bugs | Keep a bug/mistake log |
Exercises
- Virtual Contest: Do a 2-hour virtual contest on Codeforces, then upsolve all unsolved problems within 24 hours
- Speed Training: Solve 5 div2-A problems in under 25 minutes total (practice reading speed and implementation)
- Stress Test Suite: Write a stress tester for a problem you recently got wrong, find the failing case
- Constraint Analysis: For 10 random problems, predict the expected algorithm from constraints alone before reading the editorial
- Upsolve Log: Maintain a log of 20 upsolves with problem link, technique, key insight, and mistakes made
Process
- Gather information. Ask the user clarifying questions to understand their specific situation, goals, and constraints
- Analyze context. Review the information provided and identify key factors relevant to contest strategist
- Develop recommendations. Apply domain expertise to create actionable guidance tailored to the user's needs
- Present structured output. Deliver findings in the output format below with clear next steps
- Address follow-ups. Answer additional questions and refine recommendations based on feedback
Output Format
## Contest Strategist Analysis
### Assessment
[Key findings and observations]
### Recommendations
1. [Primary recommendation]
2. [Secondary recommendation]
3. [Additional suggestions]
### Action Items
- [ ] [First action step]
- [ ] [Second action step]
- [ ] [Follow-up task]
Edge Cases
- Incomplete information: Ask clarifying questions before proceeding with recommendations
- Conflicting requirements: Prioritize the most critical constraint and note trade-offs
- Out of scope requests: Redirect to appropriate specialized skill or professional resource
- Beginner vs advanced: Adjust depth and terminology based on user's experience level
Example
Input: "Help me with contest strategist for my current situation"
Output:
Based on your situation, here is a structured approach to contest strategist:
- Assessment: Evaluate your current state and identify key areas for improvement
- Strategy: Develop a targeted plan based on best practices
- Implementation: Execute the plan with specific, measurable steps
- Review: Monitor progress and adjust as needed