Skip to content

Competitive programming solutions for CSES Problem Set in C++. Covers algorithms, data structures, dynamic programming, and mathematics. Optimized for contests with fast I/O and efficient implementations.

License

Notifications You must be signed in to change notification settings

ks-iitjmu/MyCSES

MyCSES - CSES Problem Set Solutions

Hacktoberfest Contributions Welcome Code of Conduct C++

This repository contains solutions to problems from the CSES Problem Set, implemented in C++. The CSES Problem Set is a collection of competitive programming practice problems that cover various algorithmic topics.

πŸŽƒ Participating in Hacktoberfest 2025! We welcome quality contributions from the community. Check out our Contributing Guidelines to get started.

πŸ‘¨β€πŸ’» Maintainer

Kunal Sharma
IIT Jammu

🀝 Contributing

We encourage contributions from the competitive programming community! Whether you're a beginner or an expert, there are many ways to contribute:

  • πŸ› Report bugs or suggest improvements
  • πŸ’‘ Add new problem solutions
  • πŸ“š Improve documentation
  • 🎯 Optimize existing solutions
  • ✨ Add explanatory comments to complex algorithms

New to open source? Look for issues labeled good first issue to get started!

πŸ‘‰ Read our Contributing Guide for detailed instructions on how to contribute.

πŸ“‹ Code of Conduct

This project follows the Contributor Covenant Code of Conduct. By participating, you are expected to uphold this code. Please report unacceptable behavior to the maintainers.

πŸ“ Repository Structure

The solutions are organized by problem categories:

β”œβ”€β”€ 1_introductory_problems/    # Basic algorithmic problems
β”œβ”€β”€ 2_sorting_searching/        # Sorting and searching algorithms
β”œβ”€β”€ 3_dp/                      # Dynamic programming problems
β”œβ”€β”€ 7_mathematics/             # Mathematical problems
β”œβ”€β”€ .builds/                   # Build configurations
└── .vscode/                   # VS Code settings

🧩 Problem Categories

1. Introductory Problems

  • Two Sets - Partitioning numbers into two equal sum sets
  • Gray Code - Generating Gray code sequences
  • Apple Division - Minimizing difference in apple weight distribution
  • Chessboard and Queens - N-Queens problem variant
  • Coin Piles - Mathematical puzzle with coin removal rules
  • Bit Strings - Counting binary strings

2. Sorting and Searching

  • Apartments - Matching applicants to apartments
  • Movie Festival - Activity selection problem
  • Collecting Numbers - Array manipulation problems
  • Minimum Coin Sum - Finding smallest unrepresentable sum

3. Dynamic Programming

  • Minimizing Coins - Classic coin change problem

7. Mathematics

  • Exponentiation 2 - Fast exponentiation with modular arithmetic
  • Sum of Divisors - Mathematical series calculation
  • Creating Strings - Combinatorics with factorial calculations
  • Next Prime - Finding next prime
  • Christmas Party - Finding derangement of $n$ elements

πŸ”§ Implementation Details

Language & Standards

  • Language: C++
  • Compiler: Standard C++ compiler
  • Libraries: STL (Standard Template Library)

Common Patterns Used

// Standard template used across solutions
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define mod 1000000007

// Fast I/O optimization
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);

Key Algorithmic Techniques

  • Fast Exponentiation: Binary exponentiation for efficient power calculation
  • Modular Arithmetic: Using MOD = 1000000007 for large number calculations
  • Dynamic Programming: Bottom-up and memoization approaches
  • Greedy Algorithms: Activity selection and optimization problems
  • Bit Manipulation: Efficient subset generation and Gray codes
  • Mathematical Formulas: Combinatorics and number theory

πŸš€ How to Use

  1. Clone the repository:

    git clone https://github.com/ks-iitjmu/MyCSES.git
    cd MyCSES
  2. Compile a solution:

    g++ -o solution category/problem_name.cpp
  3. Run the solution:

    ./solution < input.txt

πŸ“Š Problem Solving Approach

Each solution follows a structured approach:

  1. Problem Analysis: Understanding constraints and edge cases
  2. Algorithm Selection: Choosing optimal time/space complexity approach
  3. Implementation: Clean, readable C++ code
  4. Optimization: Fast I/O and efficient algorithms for competitive programming

πŸ† Competitive Programming Features

  • Fast I/O: All solutions use optimized input/output
  • Type Definitions: Consistent use of typedef long long ll
  • Modular Arithmetic: Proper handling of large numbers
  • Edge Case Handling: Robust solutions for boundary conditions
  • Clean Code: Readable and well-structured implementations

πŸ“ˆ Progress Tracking

  • βœ… Introductory Problems: Multiple problems solved
  • βœ… Sorting and Searching: Core algorithms implemented
  • βœ… Dynamic Programming: Foundation problems completed
  • βœ… Mathematics: Advanced mathematical concepts covered

🌟 Contributors

Thanks to all the amazing contributors who have helped improve this repository!

Want to contribute? Check out our Contributing Guidelines!

πŸŽƒ Hacktoberfest

This repository participates in Hacktoberfest! We welcome quality contributions during October and throughout the year.

How to participate:

  1. Look for issues labeled hacktoberfest
  2. Check out good first issue labels for beginner-friendly tasks
  3. Read our Contributing Guidelines
  4. Submit quality pull requests
  5. Help review other contributions

Contribution Ideas:

  • Solve new CSES problems
  • Optimize existing solutions
  • Add detailed comments and explanations
  • Improve documentation
  • Add test cases
  • Create problem difficulty classifications

πŸ”— Useful Links

πŸ“ Notes

  • Solutions are optimized for competitive programming contests
  • Time complexity is prioritized for large input constraints
  • Code follows standard competitive programming conventions
  • All solutions have been tested against CSES judge system

πŸš€ Getting Started for Contributors

  1. Fork this repository
  2. Clone your fork: git clone https://github.com/YOUR_USERNAME/MyCSES.git
  3. Create a branch: git checkout -b feature/problem-name
  4. Add your solution following our guidelines
  5. Test thoroughly against CSES judge
  6. Submit a pull request

πŸ“ž Support

πŸ“œ License

This project is open source and available under the MIT License.


Feel free to explore the solutions, contribute, and use them for learning purposes. Happy coding! πŸš€

⭐ Star this repository if you find it helpful!

About

Competitive programming solutions for CSES Problem Set in C++. Covers algorithms, data structures, dynamic programming, and mathematics. Optimized for contests with fast I/O and efficient implementations.

Topics

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Releases

No releases published

Contributors 28