Skip to content

A collection of C++ solutions for various competitive programming events and platforms, including AtCoder, CSES, Codeforces, France-IOI, ICPC, IEEEXtreme, and Winter Cup.

Notifications You must be signed in to change notification settings

omar-besbes/competitive-programming

Repository files navigation

Competitive Programming Solutions

Hey there! 👋 Welcome to my repository where I keep my C/C++ solutions for various competitive programming events and platforms.

Solutions

All solutions are in the solutions directory.

Platforms I Use

You can find my solutions for problems from these platforms:

Events I Compete In

These are some of the competitive programming events I’ve participated in:

Getting started

To run the solutions in this repository, you'll need the following tools:

  • A C/C++ compiler like gcc.
  • A C/C++ debugger such as gdb (optional).
  • CMake and ninja for managing binaries.

Note

VSCode users don't have to to use CMake/Ninja anymore.
Just clone the project and you should be able to run/debug the active file directly from the run/debug button in the top right corner.

CMake/Ninja Setup Instructions

Note

Why should I use CMake to use this repository ?

Originally, I used CMake to keep the binaries (the files generated when you run/debug solutions) separate from the source files. Both CLion and VSCode support CMake, which was handy as I hadn’t settled on a specific editor at the time.
Later when I discovered that VSCode tasks and launch configurations could work without CMake, I switched to a simpler setup, while keeping CMake functionality for those who prefer it.

To be clear, CMake is not mandatory. Feel free to run the solutions however you prefer (but you'll be on your own).

This project uses CMake to compile all solution files into a separate build directory, typically named build. In my configuration, the default directory is .build, but you can change this in CMakePresets.json.

To run a solution, you'll need to configure and build the project:

  • CMake will recursively scan the repository for all cpp files during the configure step.
  • It will then compile these files during the build step, placing the binaries in .build/default/bin.
  • Binaries are named in the format: <directory_name>--<filename>.

CMake presets simplify this process, allowing you to configure and build the project with predefined settings. The repository currently includes a default preset for your convenience.

Running Solutions

There are different ways to execute solutions depending on your editor or IDE:

  • Visual Studio Code:
    Install the CMake Tools extension. You'll see new icons in the status bar, allowing you to choose a preset, build the project, and run a solution with just a few clicks.

  • CLion:
    CLion should automatically detect the CMake configuration. To run a solution, simply click the green Run button in the top-right corner of the editor.

  • Other Editors/IDEs:
    Refer to your editor's documentation for CMake integration instructions.

  • Terminal:
    If your editor/IDE doesn't support CMake integration, you can use the terminal commands:

    • First-time setup: cmake --preset default
    • Build the project: cmake --build --preset default
    • Run a solution: ./.build/default/bin/<target_name>

Reproducing This Setup in Another Repository

CMake Configuration

The CMake setup is managed through two key files: CMakeLists.txt and CMakePresets.json.

  • CMakeLists.txt: Configures how CMake detects source files and assigns target names to binaries, allowing you to run solutions without navigating to the binary's directory.

  • CMakePresets.json: Configures the build directory location, generator, and other settings.

To replicate this setup, copy these two files to your new repository and adjust them as needed.

Visual Studio Code Configuration

For VSCode, I used to use the CMake Tools extension. You may customize the status bar appearance in .vscode/settings.json. You can learn more about configuring the status bar for this extension here.

Report an issue with a solution

Generally speaking, I include solutions in this repository that have been submitted and accepted. However, there may be instances where solutions were not accepted or the version is outdated. If you encounter such issues, please feel free to open an issue in this repository.

Good luck with your problem solving! 🚀

About

A collection of C++ solutions for various competitive programming events and platforms, including AtCoder, CSES, Codeforces, France-IOI, ICPC, IEEEXtreme, and Winter Cup.

Topics

Resources

Stars

Watchers

Forks