{"id":15489049,"url":"https://github.com/vincenzopalazzo/competitive-programming-and-contests-vp-solution","last_synced_at":"2025-03-28T16:17:30.386Z","repository":{"id":45184437,"uuid":"294391749","full_name":"vincenzopalazzo/Competitive-Programming-and-Contests-VP-Solution","owner":"vincenzopalazzo","description":"The repository that contains all solutions made for the course Competitive Programming and Contests by the University of Pisa","archived":false,"fork":false,"pushed_at":"2022-01-18T20:35:08.000Z","size":20345,"stargazers_count":1,"open_issues_count":2,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-02T16:33:50.244Z","etag":null,"topics":["competitive-coding","competitive-programming","competitive-programming-contests","cpp14"],"latest_commit_sha":null,"homepage":"https://vincenzopalazzo.github.io/Competitive-Programming-and-Contests-VP-Solution/","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vincenzopalazzo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":["vincenzopalazzo"],"custom":["https://www.buymeacoffee.com/vincenzopalazzo"]}},"created_at":"2020-09-10T11:37:46.000Z","updated_at":"2022-01-17T14:07:33.000Z","dependencies_parsed_at":"2022-08-27T10:41:06.854Z","dependency_job_id":null,"html_url":"https://github.com/vincenzopalazzo/Competitive-Programming-and-Contests-VP-Solution","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vincenzopalazzo%2FCompetitive-Programming-and-Contests-VP-Solution","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vincenzopalazzo%2FCompetitive-Programming-and-Contests-VP-Solution/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vincenzopalazzo%2FCompetitive-Programming-and-Contests-VP-Solution/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vincenzopalazzo%2FCompetitive-Programming-and-Contests-VP-Solution/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vincenzopalazzo","download_url":"https://codeload.github.com/vincenzopalazzo/Competitive-Programming-and-Contests-VP-Solution/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246059337,"owners_count":20717085,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["competitive-coding","competitive-programming","competitive-programming-contests","cpp14"],"created_at":"2024-10-02T07:03:18.586Z","updated_at":"2025-03-28T16:17:30.355Z","avatar_url":"https://github.com/vincenzopalazzo.png","language":"C++","funding_links":["https://github.com/sponsors/vincenzopalazzo","https://www.buymeacoffee.com/vincenzopalazzo"],"categories":[],"sub_categories":[],"readme":"# Competitive-Programming-and-Contests-Solution\n\n![Website](https://img.shields.io/website?style=for-the-badge\u0026url=https%3A%2F%2Fvincenzopalazzo.github.io%2FCompetitive-Programming-and-Contests-VP-Solution%2F)\n![GitHub Workflow Status](https://img.shields.io/github/workflow/status/vincenzopalazzo/Competitive-Programming-and-Contests-VP-Solution/URL%20Checker?label=URL%20SAFETY\u0026style=for-the-badge)\n\nThis repository contains the solution to the problems proposed at the Course of [Competitive Programming](https://github.com/rossanoventurini/CompetitiveProgramming)\nby the University of Pisa.\n\n## Table of Content\n\n- Introduction\n- Built with\n- Problems with a brief discussion about them\n- How to build the solutions\n- How to contribute\n- License\n\n## Introduction\n\nEach solution is provided with a battery of unit tests and a code structure under the src directory that looks like the following tree:\n\n- src\n    - test\n      - *Main.cpp*: Tests units where is possible to test the solution in local with the test result on the console.\n      - **.hpp*: A couple of files to implement the test tools, implemented inside the repository [cpstl](https://vincenzopalazzo.github.io/cpstl/)\n    - core\n      - *SolutionName.hpp*: a file that contains the solution of the problem\n      - One or more data structure file implemented inside the repository [cpstl](https://vincenzopalazzo.github.io/cpstl/)\n    - *MainSite.cpp*: The file that contains the solution for the online judge\n    - *CMakeFile*\n\nSome solutions are provided with different implementations (where is present or covered by the developer) with complete benchmarks developed with [Google benchmark](https://github.com/google/benchmark).\nThe result is stored inside a JSON or a CVS file called *result* and the machine where there are running has the following characteristic.\n\n- OS: Linuxmint 20.1 ulyssa\n- CPU: Intel Core i5-6300U @ 4x 3GHz\n- RAM: 16 GB.\n\nSome of these benchmarks have a complete discussion with the Jupiter Notebook, see the last column of the tables below.\n\n\u003e If you want to run the benchmark on your own computer and your computer is a personal computer, in some cases you need to disable some machine setting, but you can follow\n[this answer](https://stackoverflow.com/a/48110959/10854225) on StackOverflow (If you are using a linux machine)\n\n## Built with\n\nAll the solutions are developed with C++ STD, and also with a couple of external tools reported below:\n\n- [CPSTL](https://vincenzopalazzo.github.io/cpstl): Competitive Programming Standard \"library\", is a new project with the object to include a complete collection of algorithms and data structure to use in the Competitive Programming problem. Also, it is open to support different programming languages.\n- [Google benchmark](https://github.com/google/benchmark): A Google framework to make cool micro benchmarks, you need to install it if you want to run the benchmarks in some problem, otherwise you can avoid installing it.\n\n## Problems with a briefly discussion about them\n\nName | Solved | Repository | Report |\n--- | --- | --- | --- |\n*Leaders in array* | :heavy_check_mark: | [Code](https://vincenzopalazzo.github.io/Competitive-Programming-and-Contests-VP-Solution/LeadersInArray) | _ |\n*Kadane's algorithm* | :heavy_check_mark: | [Code](https://vincenzopalazzo.github.io/Competitive-Programming-and-Contests-VP-Solution/KadanesAlgorithm) | _ |\n*Missing number in array* | :heavy_check_mark: | [Code](https://vincenzopalazzo.github.io/Competitive-Programming-and-Contests-VP-Solution/MissingNumberInArray) | _ |\n*Trapping rain water* | :heavy_check_mark: | [Code](https://vincenzopalazzo.github.io/Competitive-Programming-and-Contests-VP-Solution/TrappingRainWater) | _ |\n*Sliding window maximum* | :heavy_check_mark: | [Code](https://vincenzopalazzo.github.io/Competitive-Programming-and-Contests-VP-Solution/SlidingWindowMaximum) | [Class Report](https://vincenzopalazzo.github.io/Competitive-Programming-and-Contests-VP-Solution/SlidingWindowMaximum/benchmark/docs) |\n*Next larger element* | :heavy_check_mark: | [Code](https://vincenzopalazzo.github.io/Competitive-Programming-and-Contests-VP-Solution/NextLargerElement) | _ |\n*Towers* | :heavy_check_mark: | [Code](https://vincenzopalazzo.github.io/Competitive-Programming-and-Contests-VP-Solution/Towers) | _ |\n*Finding Team Member* | :heavy_check_mark: | [Code](https://vincenzopalazzo.github.io/Competitive-Programming-and-Contests-VP-Solution/FindingTeamMember) | _ |\n*The Monkey and the Oiled Bamboo* | :heavy_check_mark:  | [Code](https://vincenzopalazzo.github.io/Competitive-Programming-and-Contests-VP-Solution/MonkeyAndBamboo) | _ |\n*Inversion count* | :heavy_check_mark: | [Code](https://vincenzopalazzo.github.io/Competitive-Programming-and-Contests-VP-Solution/InversionCounting) | _ |\n*Two Types of Spells* | :heavy_check_mark: | [Code](https://vincenzopalazzo.github.io/Competitive-Programming-and-Contests-VP-Solution/TwoTypesofSpells) | _ |\n*Frogs and Mosquitoes* | :heavy_check_mark: | [Code](https://vincenzopalazzo.github.io/Competitive-Programming-and-Contests-VP-Solution/FrogsAndMosquitoes) | _ |\n*Maximum path sum* | :heavy_check_mark: | [Code](https://vincenzopalazzo.github.io/Competitive-Programming-and-Contests-VP-Solution/MaximumPathSumBetween2LeafNodes) | _ |\n*Longest k Good Segment* | :heavy_check_mark: | [Code](https://vincenzopalazzo.github.io/Competitive-Programming-and-Contests-VP-Solution/LongestkGoodSegment) | _ |\n*Ilya and Queries* | :heavy_check_mark: | [Code](https://vincenzopalazzo.github.io/Competitive-Programming-and-Contests-VP-Solution/IlyaAndQueries) | _ |\n*Number of ways* | :heavy_check_mark: | [Code](https://vincenzopalazzo.github.io/Competitive-Programming-and-Contests-VP-Solution/NumberOfWays) | _ |\n*Little girl and maximum sum* | :heavy_check_mark: | [Code](https://vincenzopalazzo.github.io/Competitive-Programming-and-Contests-VP-Solution/LittleGirlandMaximumSum) | _ |\n*Update the array* | :heavy_check_mark: | [Code](https://vincenzopalazzo.github.io/Competitive-Programming-and-Contests-VP-Solution/UpdateTheArray) | _ |\n*Nested segments (also segment tree)* | 3/3 :heavy_check_mark: | [Code](https://vincenzopalazzo.github.io/Competitive-Programming-and-Contests-VP-Solution/NestedSegments) | _ |\n*Pashmak and Parmida's problem* | :heavy_check_mark: | [Code](https://vincenzopalazzo.github.io/Competitive-Programming-and-Contests-VP-Solution/PashmakAndParmida) | _ |\n*Circular RMQ* | :heavy_check_mark: | [Code](https://vincenzopalazzo.github.io/Competitive-Programming-and-Contests-VP-Solution/CircularRMQ) | [Benchmarks](https://vincenzopalazzo.github.io/Competitive-Programming-and-Contests-VP-Solution/CircularRMQ/benchmark/results/CircularRMQ_benchmark/) |\n*Triplets* | :heavy_check_mark: | [Code](https://vincenzopalazzo.github.io/Competitive-Programming-and-Contests-VP-Solution/Triplets) | _ |\n*Smaller Values* | 1/3 :heavy_check_mark: | [Code](https://vincenzopalazzo.github.io/Competitive-Programming-and-Contests-VP-Solution/SmallerValues) | _ |\n*Powerful array* | :heavy_check_mark: | [Code](https://vincenzopalazzo.github.io/Competitive-Programming-and-Contests-VP-Solution/PowerfulArray) | _ |\n*Tree and queries* | :heavy_check_mark: | [Code](https://vincenzopalazzo.github.io/Competitive-Programming-and-Contests-VP-Solution/TreeAndQueries) | _ |\n*Longest common subsequence* | :heavy_check_mark:  | [Code](https://vincenzopalazzo.github.io/Competitive-Programming-and-Contests-VP-Solution/LongestCommonSubsequence) | _ |\n*Minimum number of jumps* | :heavy_check_mark: | [Code](https://vincenzopalazzo.github.io/Competitive-Programming-and-Contests-VP-Solution/MinimumNumberOfJumps) | _ |\n*Subset sum* | 4/4 :heavy_check_mark: | [Code](https://vincenzopalazzo.github.io/Competitive-Programming-and-Contests-VP-Solution/PartitionEqualSubsetSum) | _ |\n*0-1 knapsack* | :heavy_check_mark: | [Code](https://vincenzopalazzo.github.io/Competitive-Programming-and-Contests-VP-Solution/01knapsack) | _ |\n*Longest increasing subsequence* | :heavy_check_mark: | [Code](https://vincenzopalazzo.github.io/Competitive-Programming-and-Contests-VP-Solution/LongestIncreasingSubsequence) | _ |\n*Longest bitonic subsequence* | :heavy_check_mark: | [Code](https://vincenzopalazzo.github.io/Competitive-Programming-and-Contests-VP-Solution/LongestBitonicSubsequence) | _ |\n*Edit distance* | :heavy_check_mark: | [Code](https://vincenzopalazzo.github.io/Competitive-Programming-and-Contests-VP-Solution/EditDistance) | _ |\n*Vertex cover* | :heavy_check_mark: | [Code](https://vincenzopalazzo.github.io/Competitive-Programming-and-Contests-VP-Solution/VertexCover) | _ |\n*Longest palindromic subsequence* | :heavy_check_mark: | [Code](https://vincenzopalazzo.github.io/Competitive-Programming-and-Contests-VP-Solution/LongestPalindromicSubsequence) | _ |\n*N meetings in one room* | :heavy_check_mark: | [Code](https://vincenzopalazzo.github.io/Competitive-Programming-and-Contests-VP-Solution/NMeetingsInOneRoom) | _ |\n*Magic numbers* | :heavy_check_mark: | [Code](https://vincenzopalazzo.github.io/Competitive-Programming-and-Contests-VP-Solution/MagicNumbers) | _ |\n*Wilbur and array* | :heavy_check_mark: | [Code](https://vincenzopalazzo.github.io/Competitive-Programming-and-Contests-VP-Solution/WilburAndArray) | _ |\n*Alternativ e thinking* | :heavy_check_mark: | [Code](https://vincenzopalazzo.github.io/Competitive-Programming-and-Contests-VP-Solution/AlternativeThinking) | _ |\n\n## Segment Tree report\n\nDuring the Courses is developed also a small paper to introduce the Segment tree by Examples. [\"Segment Tree: A Complete Introduction by Examples\"](https://gitlab.com/vincenzopalazzo/competitiveprogrammingreport/uploads/b2dcff843e34eedfab80fb737126b465/report.pdf)\n\n## Report Experiments\n\nName | Solved | Repository | Report |\n--- | --- | --- | --- |\n*RMQ* | :heavy_check_mark: | [Code](https://vincenzopalazzo.github.io/Competitive-Programming-and-Contests-VP-Solution/Appendix/report_experiment/RMQ) | [Benchmarks](https://vincenzopalazzo.github.io/Competitive-Programming-and-Contests-VP-Solution/Appendix/report_experiment/RMQ/benchmark/results/RMQ_benchmark) |\n*Circular RMQ* | :heavy_check_mark: | [Code](https://vincenzopalazzo.github.io/Competitive-Programming-and-Contests-VP-Solution/CircularRMQ) | [Benchmarks](https://vincenzopalazzo.github.io/Competitive-Programming-and-Contests-VP-Solution/CircularRMQ/benchmark/results/CircularRMQ_benchmark/) |\n*Kth Zero* | :heavy_check_mark: | [Code](https://vincenzopalazzo.github.io/Competitive-Programming-and-Contests-VP-Solution/Appendix/report_experiment/FindKthZero) | _ |\n*MKTHNUM* | :heavy_check_mark: | [Code](https://vincenzopalazzo.github.io/Competitive-Programming-and-Contests-VP-Solution/Appendix/report_experiment/MKTHNUM) | [Benchmarks](https://vincenzopalazzo.github.io/Competitive-Programming-and-Contests-VP-Solution/Appendix/report_experiment/MKTHNUM/benchmark/result/MKTHNUM_benchmark) |\n*Range Updates and Sums* | :construction: | [Code](https://vincenzopalazzo.github.io/Competitive-Programming-and-Contests-VP-Solution/Appendix/report_experiment/RangeUpdatesSums/) | _ |\n\n\n## Appendix\n\nName | Solved | Repository |\n--- | --- | --- |\n*DQUERY* | :heavy_check_mark: | [Code](https://vincenzopalazzo.github.io/Competitive-Programming-and-Contests-VP-Solution/Appendix/extra/DQUERY) |\n*FibonacciNum* | :heavy_check_mark: | [Code](https://vincenzopalazzo.github.io/Competitive-Programming-and-Contests-VP-Solution/Appendix/extra/FibonacciNum) |\n*ClotestValueOnBST* | :construction: | [Code](https://vincenzopalazzo.github.io/Competitive-Programming-and-Contests-VP-Solution/Appendix/extra/ClotestValueOnBST) |\n*TwoNumberSum* | :heavy_check_mark: | [Code](https://vincenzopalazzo.github.io/Competitive-Programming-and-Contests-VP-Solution/Appendix/extra/TwoNumberSum) |\n\n#### Google kikstart 2020\n\nName | Solved | Repository |\n--- | --- | --- |\n*Allocation* | :heavy_check_mark: | [Code](https://vincenzopalazzo.github.io/Competitive-Programming-and-Contests-VP-Solution/Appendix/google_kikstart/roundA_2020_Allocation) |\n*Plates* | :construction: | [Code](https://vincenzopalazzo.github.io/Competitive-Programming-and-Contests-VP-Solution/Appendix/google_kikstart/roundA_2020_Plates) |\n\n## How to build the solutions\n\nEach solution contains a complete test unit developed with a Test tool developed ad-hock as a \"Copy and Paste\" code, and to build the project to run the\ntest the following commands are required\n\n```bash\n\u003e\u003e mkdir build \u0026\u0026 cd build\n\u003e\u003e cmake .. \u0026\u0026 make\n\u003e\u003e ./NameSolution\n```\n\nOne possible output is reported below\n\n```bash\n|------------ TEST TEST_CASE_ONE_SEGMENT_TREE -------------------|\nTEST_CASE_ONE_SEGMENT_TREE PASSED\n|------------ TEST TEST_CASE_ONE_LAZY_SEGMENT_TREE -------------------|\nTEST_CASE_ONE_LAZY_SEGMENT_TREE PASSED\n|------------ TEST TEST_CASE_TWO_LAZY_SEGMENT_TREE -------------------|\nTEST_CASE_TWO_LAZY_SEGMENT_TREE PASSED\n|------------ TEST TEST_CASE_THREE_LAZY_SEGMENT_TREE -------------------|\nTEST_CASE_THREE_LAZY_SEGMENT_TREE PASSED\n```\n\n## How to contribute\n\nThe repository is open to receive a contribution to improving solutions or the quality of the repository, there are only a few rules to respect that are reported\nbelow.\n\n- Each solution need to start with the C++ template project, available [here](https://github.com/vincenzopalazzo/Competitive-Programming-and-Contests-VP-Solution/tree/master/template)\n- Each code that is inside the repository needs to follow the well-formatted code guidelines, so if the solution uses the C++ classes the Google code style needs to be included in the solution. _clang-format_ file available [at the following link](https://github.com/vincenzopalazzo/cpstl/blob/master/.clang-format), otherwise is the C++ is without classes a Linux Kernel guidelines need to\nbe included _clang-format_ file available [at the following link](https://github.com/vincenzopalazzo/Competitive-Programming-and-Contests-VP-Solution/blob/master/template/.clang-format).\n- New implementation of data structure needs to be push also in repository [cpstl](https://vincenzopalazzo.github.io/cpstl/).\n- Each solution, need to contain a Readme with some details about the implementation and the time execution on the online Judge, one\nexample can be the following [solution](https://vincenzopalazzo.github.io/Competitive-Programming-and-Contests-VP-Solution/Appendix/extra/FibonacciNum/)\n- Have fun.\n\n## License\n\n\u003cdiv align=\"center\"\u003e\n  \u003cimg src=\"https://opensource.org/files/osi_keyhole_300X300_90ppi_0.png\" width=\"150\" height=\"150\"/\u003e\n\u003c/div\u003e\n\nall the professor of the class Competitive Programming and Contest\nhttps://github.com/rossanoventurini/CompetitiveProgramming\n\nCopyright (c) 2020-2021 Vincenzo Palazzo vincenzopalazzodev@gmail.com and\n\nThis program is free software; you can redistribute it and/or\nmodify it under the terms of the GNU General Public License\nas published by the Free Software Foundation; either version 2\nof the License, or (at your option) any later version.\n\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with this program; if not, write to the Free Software\nFoundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvincenzopalazzo%2Fcompetitive-programming-and-contests-vp-solution","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvincenzopalazzo%2Fcompetitive-programming-and-contests-vp-solution","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvincenzopalazzo%2Fcompetitive-programming-and-contests-vp-solution/lists"}