This repository contains competitive programming exercises and solutions developed during my Bachelor's degree in Computer Science at the University of Trento.
-
Categories/: Solutions organized by algorithmic topic. Each subdirectory corresponds to a category, such as:Super_easy: Beginner-level problems.Ad_hoc: Ad hoc problem-solving.7 - Simulation: Simulation problems.String_processing: String manipulation tasks.Maths: Mathematical and number theory problems.Data_structures: Data structure implementations and problems.Graphs: Graph algorithms and problems.Dynamic_programming: Dynamic programming problems.Backtracking: Backtracking and exhaustive search.Grid: Grid-based puzzles and problems.
-
Doc_files/: Code templates and snippets (e.g., Fenwick tree, segment tree for RMQ/RSQ, priority queue examples, string splitting) for quick reference. -
Work_in_progress/: In-progress or experimental problem solutions.
Each solution is implemented in C++ (typically C++11 or newer). Sample input (*.in) and expected output (*.ans) files are provided alongside many solutions. To compile and test a solution against its sample:
# Compile the solution
g++ -std=c++17 -O2 -o <problem> <problem>.cpp
# Run with sample input and compare the output
./<problem> < <problem>.in > output.ans
diff -u <problem>.ans output.ansAdjust compiler flags and standard version as needed.
The Doc_files directory contains reusable templates:
| File | Description |
|---|---|
base.cpp |
Base template with fast I/O setup and main entry point. |
dyn_RMQ-RSQ.cpp |
Segment tree for range minimum/maximum queries (RMQ/RSQ). |
fenwick_tree.cpp |
Fenwick (BIT) tree implementation. |
priority_queue.cpp |
Examples of custom comparators with priority queues. |
split.cpp |
String splitting utility using stringstream. |
Many categories include a README.md file with problem-specific notes and tips (often written in Italian).
Feel free to explore the solutions and templates. If you notice any improvements or corrections, please fork this repository and submit a pull request.
This repository is for personal reference. Please do not redistribute without permission.