The repository that contains all solutions made for the course Competitive Programming and Contests by the University of Pisa
This repository contains the solution to the problems proposed at the Course of Competitive Programming by the University of Pisa.
Each solution is provided with a battery of unit tests and a code structure under the src directory that looks like the following tree:
Some solutions are provided with different implementations (where is present or covered by the developer) with complete benchmarks developed with Google benchmark. The result is stored inside a JSON or a CVS file called result and the machine where there are running has the following characteristic.
Some of these benchmarks have a complete discussion with the Jupiter Notebook, see the last column of the tables below.
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 this answer on StackOverflow (If you are using a linux machine)
All the solutions are developed with C++ STD, and also with a couple of external tools reported below:
Name | Solved | Repository | Report |
---|---|---|---|
Leaders in array | ![]() |
Code | _ |
Kadane’s algorithm | ![]() |
Code | _ |
Missing number in array | ![]() |
Code | _ |
Trapping rain water | ![]() |
Code | _ |
Sliding window maximum | ![]() |
Code | Class Report |
Next larger element | ![]() |
Code | _ |
Towers | ![]() |
Code | _ |
Finding Team Member | ![]() |
Code | _ |
The Monkey and the Oiled Bamboo | ![]() |
Code | _ |
Inversion count | ![]() |
Code | _ |
Two Types of Spells | ![]() |
Code | _ |
Frogs and Mosquitoes | ![]() |
Code | _ |
Maximum path sum | ![]() |
Code | _ |
Longest k Good Segment | ![]() |
Code | _ |
Ilya and Queries | ![]() |
Code | _ |
Number of ways | ![]() |
Code | _ |
Little girl and maximum sum | ![]() |
Code | _ |
Update the array | ![]() |
Code | _ |
Nested segments (also segment tree) | 3/3 ![]() |
Code | _ |
Pashmak and Parmida’s problem | ![]() |
Code | _ |
Circular RMQ | ![]() |
Code | Benchmarks |
Triplets | ![]() |
Code | _ |
Smaller Values | 1/3 ![]() |
Code | _ |
Powerful array | ![]() |
Code | _ |
Tree and queries | ![]() |
Code | _ |
Longest common subsequence | ![]() |
Code | _ |
Minimum number of jumps | ![]() |
Code | _ |
Subset sum | 4/4 ![]() |
Code | _ |
0-1 knapsack | ![]() |
Code | _ |
Longest increasing subsequence | ![]() |
Code | _ |
Longest bitonic subsequence | ![]() |
Code | _ |
Edit distance | ![]() |
Code | _ |
Vertex cover | ![]() |
Code | _ |
Longest palindromic subsequence | ![]() |
Code | _ |
N meetings in one room | ![]() |
Code | _ |
Magic numbers | ![]() |
Code | _ |
Wilbur and array | ![]() |
Code | _ |
Alternativ e thinking | ![]() |
Code | _ |
During the Courses is developed also a small paper to introduce the Segment tree by Examples. “Segment Tree: A Complete Introduction by Examples”
Name | Solved | Repository | Report |
---|---|---|---|
RMQ | ![]() |
Code | Benchmarks |
Circular RMQ | ![]() |
Code | Benchmarks |
Kth Zero | ![]() |
Code | _ |
MKTHNUM | ![]() |
Code | Benchmarks |
Range Updates and Sums | ![]() |
Code | _ |
Name | Solved | Repository |
---|---|---|
DQUERY | ![]() |
Code |
FibonacciNum | ![]() |
Code |
ClotestValueOnBST | ![]() |
Code |
TwoNumberSum | ![]() |
Code |
Name | Solved | Repository |
---|---|---|
Allocation | ![]() |
Code |
Plates | ![]() |
Code |
Each 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 test the following commands are required
>> mkdir build && cd build
>> cmake .. && make
>> ./NameSolution
One possible output is reported below
|------------ TEST TEST_CASE_ONE_SEGMENT_TREE -------------------|
TEST_CASE_ONE_SEGMENT_TREE PASSED
|------------ TEST TEST_CASE_ONE_LAZY_SEGMENT_TREE -------------------|
TEST_CASE_ONE_LAZY_SEGMENT_TREE PASSED
|------------ TEST TEST_CASE_TWO_LAZY_SEGMENT_TREE -------------------|
TEST_CASE_TWO_LAZY_SEGMENT_TREE PASSED
|------------ TEST TEST_CASE_THREE_LAZY_SEGMENT_TREE -------------------|
TEST_CASE_THREE_LAZY_SEGMENT_TREE PASSED
The 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 below.
all the professor of the class Competitive Programming and Contest https://github.com/rossanoventurini/CompetitiveProgramming
Copyright (c) 2020-2021 Vincenzo Palazzo vincenzopalazzodev@gmail.com and
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.