This repo contains personal validated answers to the CSES online platform questions about competitive programming.
CSES is a collection of solutions to competitive programming problems from the CSES Problem Set (cses.fi). Each file contains a validated, accepted solution to a specific problem, demonstrating efficient algorithms and problem-solving techniques in C.
The repository contains individual C files, each solving a distinct CSES problem:
weirdAlgorithm.c: Solution to the Weird Algorithm problem
// Implements the Collatz conjecture sequencemissing.c: Solution to the Missing Number problem
// Finds the missing number in a sequence from 1 to nmoves.c: Solution to a moves-based problem
// Calculates optimal moves or sequencesdna.c: Solution to a DNA sequence problem
// Processes and analyzes DNA string patterns- Competitive Programming Solutions: Each file solves a specific algorithmic challenge
- Optimized Code: Solutions are written to pass CSES time and memory constraints
- Standard Input/Output: Programs read from stdin and write to stdout as per CSES format
- Validated Answers: All solutions have been accepted by the CSES platform
When tackling a CSES problem:
- Understand the problem constraints and requirements
- Design an efficient algorithm (often O(n) or O(n log n))
- Implement the solution in C with careful memory management
- Test with sample inputs and edge cases
- Submit to CSES and validate acceptance
- Algorithm Design: Efficient solutions to classic competitive programming problems
- C Programming: Low-level control, pointers, and memory management
- Time Complexity: Optimizing for speed to meet strict time limits
- Standard I/O: Fast input/output handling for large datasets
- Problem Decomposition: Breaking complex problems into manageable steps
- Clone the repository:
git clone https://github.com/achille010/cses.git
cd cses- Compile a solution:
gcc -o weirdAlgorithm weirdAlgorithm.c- Run the executable:
./weirdAlgorithm- Or compile with optimization flags:
gcc -O2 -o weirdAlgorithm weirdAlgorithm.c# Input: 3
# Output: 3 10 5 16 8 4 2 1# Input: n=5, numbers: 1 2 4 5
# Output: 3- Solutions are problem-specific and not generalized
- No test cases included in the repository
- Assumes familiarity with CSES problem statements
- Code is optimized for correctness and speed, not necessarily readability
This is intentionally focused on competitive programming solutions for the CSES platform.
- C compiler (gcc, clang, or similar)
- Basic understanding of algorithms and data structures
- Access to CSES problem set for problem statements
Contributions are welcome! Feel free to fork this repository and submit pull requests for improvements.
MIT License - Read details from the LICENSE file
Built as a collection of validated CSES competitive programming solutions