Competitive-Programming-and-Contests-VP-Solution

The repository that contains all solutions made for the course Competitive Programming and Contests by the University of Pisa

View the Project on GitHub

Competitive-Programming-and-Contests-Solution

Website GitHub Workflow Status

This repository contains the solution to the problems proposed at the Course of Competitive Programming by the University of Pisa.

Table of Content

Introduction

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)

Built with

All the solutions are developed with C++ STD, and also with a couple of external tools reported below:

Problems with a briefly discussion about them

Name Solved Repository Report
Leaders in array :heavy_check_mark: Code _
Kadane’s algorithm :heavy_check_mark: Code _
Missing number in array :heavy_check_mark: Code _
Trapping rain water :heavy_check_mark: Code _
Sliding window maximum :heavy_check_mark: Code Class Report
Next larger element :heavy_check_mark: Code _
Towers :heavy_check_mark: Code _
Finding Team Member :heavy_check_mark: Code _
The Monkey and the Oiled Bamboo :heavy_check_mark: Code _
Inversion count :heavy_check_mark: Code _
Two Types of Spells :heavy_check_mark: Code _
Frogs and Mosquitoes :heavy_check_mark: Code _
Maximum path sum :heavy_check_mark: Code _
Longest k Good Segment :heavy_check_mark: Code _
Ilya and Queries :heavy_check_mark: Code _
Number of ways :heavy_check_mark: Code _
Little girl and maximum sum :heavy_check_mark: Code _
Update the array :heavy_check_mark: Code _
Nested segments (also segment tree) 3/3 :heavy_check_mark: Code _
Pashmak and Parmida’s problem :heavy_check_mark: Code _
Circular RMQ :heavy_check_mark: Code Benchmarks
Triplets :heavy_check_mark: Code _
Smaller Values 1/3 :heavy_check_mark: Code _
Powerful array :heavy_check_mark: Code _
Tree and queries :heavy_check_mark: Code _
Longest common subsequence :heavy_check_mark: Code _
Minimum number of jumps :heavy_check_mark: Code _
Subset sum 4/4 :heavy_check_mark: Code _
0-1 knapsack :heavy_check_mark: Code _
Longest increasing subsequence :heavy_check_mark: Code _
Longest bitonic subsequence :heavy_check_mark: Code _
Edit distance :heavy_check_mark: Code _
Vertex cover :heavy_check_mark: Code _
Longest palindromic subsequence :heavy_check_mark: Code _
N meetings in one room :heavy_check_mark: Code _
Magic numbers :heavy_check_mark: Code _
Wilbur and array :heavy_check_mark: Code _
Alternativ e thinking :heavy_check_mark: Code _

Segment Tree report

During the Courses is developed also a small paper to introduce the Segment tree by Examples. “Segment Tree: A Complete Introduction by Examples”

Report Experiments

Name Solved Repository Report
RMQ :heavy_check_mark: Code Benchmarks
Circular RMQ :heavy_check_mark: Code Benchmarks
Kth Zero :heavy_check_mark: Code _
MKTHNUM :heavy_check_mark: Code Benchmarks
Range Updates and Sums :construction: Code _

Appendix

Name Solved Repository
DQUERY :heavy_check_mark: Code
FibonacciNum :heavy_check_mark: Code
ClotestValueOnBST :construction: Code
TwoNumberSum :heavy_check_mark: Code

Google kikstart 2020

Name Solved Repository
Allocation :heavy_check_mark: Code
Plates :construction: Code

How to build the solutions

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

How to contribute

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.

License

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.