adbo-ITU / APS23-exam

The exam project for Algorithmic Problem Solving 2023 at ITU, consisting of a self-designed Kattis problem and solutions for self-selected Kattis problems.
0 stars 0 forks source link

Initial sample solution for Kattis problem #1

Closed avborup closed 1 year ago

avborup commented 1 year ago

This issue outlines our initial, basic version of the problem.

Description

A band is performing at this year's Copenhell, and to finish off their concert in style, they would like to crowdsurf from the stage all the way from the stage to the back of the crowd.

However, the band is not sure that the crowd will be able to carry all of them through. They're unsure how strong the people in the crowd are, so to be sure, each person in the crowd would have to carry at most one band member over the course of the crowdsurfing.

The people in the crowd will only pass band members to other crowd members behind them - that is, people further away from the scene than themselves.

Input

4 9 3
.###..#.#
..#..##.#
#....##.#
..#...##.

Output

The number of band members not able to crowdsurf. I.e. how many band members remain standing on the stage.

Expected output for above input is 1. Two band members can surf the two rightmost paths. The remaining band member has nowhere to surf.

Intended solution

Number of node-disjoint paths, calculated using a maximum flow algorithm.

avborup commented 1 year ago

Ideas for extensions:

AMB-F commented 1 year ago

Some very simple input/output

Basic one row

Input:

1 9 10
...###...

Answer: 7

Basic two row

Input:

2 9 20
...###...
....#....

Answer: 19

Full crowd

Input:

3 6 3
######
######
######

Answer: 0

Empty crowd

input:

3 6 3
......
......
......

Answer: 3

Two paths join

Input:

3 3 3
#.#
#.#
.#.

Answer: 2

Simple straight line

Input:

3 3 3
.#.
.#.
.#.

Answer: 2

Simple diaginal (examples of both directions)

Diagonal rightwards

Input:

3 3 3
#..
.#.
..#

Answer: 2

Diagonal leftwards

Input:

3 3 3
..#
.#.
#..

Answer: 2

JoachimBorup commented 1 year ago

To catch solutions that scale with the number of possible entry points or exit points. Hidden cases with huge inputs, that look something like the cases below:

Many-to-few:

Input:

5 9 5
#.#.#.#.#
.###.###.
..#.#.#..
...###...
....#....

Answer: 4

Few-to-many:

Input:

5 9 5
....#....
...###...
..#.#.#..
.###.###.
#.#.#.#.#

Answer: 4

Many-to-many:

Input:

5 9 5
#.#.#.#.#
.###.###.
..#.#.#..
.###.###.
#.#.#.#.#

Answer: 2

AMB-F commented 1 year ago

Feedback from TA

Input Use the 0,1,2 beers idea for crowdmembers and have every bandmember weigh 1 Might need something else than the grid, so IO does not take too long. We need input large enough that the optimal flow algorithm is the only solution that can give full points, the problem should not be solvable just using greedy

Some options for grading groups Input size Carrying capacity of crowd (all 0, all mixed) Complexity of hand-over (always moving away form stage or mix) Number of band members (1 or many)

Look at running times for the different flow algorithms and chose the one optimal for our input