This repository contains solutions to problems from Codeforces, implemented in C++ and Java. The repository is designed with portability, automation, and efficiency in mind, utilizing Docker for a consistent development environment and Visual Studio Code (VSCode) integration for seamless coding.
-
Multi-Language Support:
- Solutions implemented in C++ (
cf_cpp/
) and Java (cf_java/
). - Support for competitive programming workflows in both languages.
- Solutions implemented in C++ (
-
Docker Integration:
- Portable environment for C++ solutions using Docker. Ensures compatibility and eliminates dependency issues.
-
VSCode Snippets and Tasks:
- C++ snippets: Triggered using
cfcpp
. - Java snippets: Triggered using
cpj
. - Tasks to automate input/output file generation and testing.
- C++ snippets: Triggered using
-
Automated Workflow:
- Input/output file creation using
build.sh
. - Dynamic testing of solutions by modifying
choice
inmain.cpp
.
- Input/output file creation using
-
Organized Directory Structure:
- Separate directories for solutions (
probs
), input/output files, and configurations.
- Separate directories for solutions (
.
├── cf_cpp/ # C++ solutions and setup
│ ├── build.sh # Script to compile and run C++ solutions
│ ├── create_files.py # Script to generate input/output files
│ ├── Dockerfile # Docker setup for portable environment
│ ├── includes.h # Common header file for C++ solutions
│ ├── main.cpp # Entry point for testing solutions
│ ├── problem_map.h # Map linking problem IDs to filenames
│ ├── input/ # Directory for input test cases
| | └── prob_{problemID}_in.txt # C++ referance input file (e.g., prob_118A_in.txt)
│ ├── output/ # Directory for output test cases
| | └── prob_{problemID}_out.txt # C++ referance output file (e.g., prob_118A_out.txt)
│ ├── probs/ # Directory for problem solutions in C++
| | └── prob_{problemID}.cpp # C++ solutions (e.g., prob_118A.cpp)
│ └── .vscode/ # VSCode configurations for C++
│ ├── cf_cpp.code-snippets # C++ snippets for competitive programming
│ ├── settings.json # VSCode settings
│ └── tasks.json # Tasks for automated workflows
│
└── cf_java/ # Java solutions and setup
├── prob_{problemID}.java # Java solutions (e.g., prob_118A.java)
└── .vscode/ # VSCode snippets for Java
└── cpjava.code-snippets # Java snippets for competitive programming
- Build the Docker image:
docker build -t cf_cpp .
- Run the container:
docker run -it --rm -v $(pwd):/workspace cf_cpp
- Run the solutions:
./build.sh
- Prerequisites: Install GCC and Bash.
- Run the solutions:
./build.sh
- Open the repository in Visual Studio Code.
- Use
cfcpp
as a snippet prefix for C++ templates. - Press
Ctrl + Shift + B
to:- Generate input/output files in
input/
andoutput/
. - Run the configured task for Create Input Outpu Files. (python3 required)
- Generate input/output files in
- Add the problem's input and output to:
cf_cpp/input/prob_{problemID}_in.txt
cf_cpp/output/prob_{problemID}_out.txt
- Modify the
choice
variable inmain.cpp
to the respective{problemID}
. - Run
./build.sh
to test the solution.
- Prerequisites: Install Java JDK.
- Compile and run a Java solution:
javac prob_{problemID}.java java prob_{problemID}
- Use
cpj
as a snippet prefix for Java templates. - Java snippets are defined in
cpjava.code-snippets
for competitive programming needs.
- Solution Files:
- C++:
cf_cpp/probs/prob_{problemID}.cpp
- Java:
cf_java/prob_{problemID}.java
- C++:
- Input Files:
cf_cpp/input/prob_{problemID}_in.txt
- Output Files:
cf_cpp/output/prob_{problemID}_out.txt
Contributions are welcome! Follow these steps to contribute:
- Fork the repository.
- Add or improve solutions/scripts.
- Submit a pull request with a clear description of changes.
This repository is licensed under the MIT License. See the LICENSE file for details.
For any questions or feedback, please open an issue in this repository. Also email Raiyan_Ibrahim
Note: This repository is a personal project and is not affiliated with Codeforces.