Course Home | Assignments | Schedule & Lecture Notes

Saint Louis University

Computer Science 3100
Algorithms

Michael Goldwasser

Fall 2016

Dept. of Computer Science

Homework Assignment 05

Network Flow


Overview

Topics: Applications of Network Flow
Related Reading: Chapter 26 of CLRS
Due: 10:00am, Friday, December 2, 2016

You must adhere to the policies on academic integrity, paying particular attention to the limits on collaboration.


Table of Contents


Overview

For this homework, you are to develop an implementation for a programming contest problem found at open.kattis.com/problems/catvsdog. You may program in any language that is accepted by the kattis site (currently C, C# C++, Go, Haskell, Java, JavaScript, Objective-C, PHP, Prolog, Python 2, Python 3, Ruby). Note that your solution must not only pass the automated tests on the kattis site, but also produce some extraneous trace information that demonstrates how the optimal solution may be achieved.

We discussed this problem during a class meeting, but for convenience, we provide here a very brief summary of how to model this problem and its relationship to network flow.


Testing on open.kattis.com

To be successful on this assignment, you must develop a solution that is "accepted" by open.kattis.com. You will need to register for an account in order to submit solutions, but registration is free.

To be accepted by that software, your program must read its input from the standard input stream in whatever language you use (e.g., cin in C++, or System.in in Java), with the input format being precisely what is described in the problem statement. It must also output precisely the expected results on the standard output stream (e.g., cout in C++ or System.out in Java), and it must not output any other extraneous information on the standard output stream. You may, however, output any extraneous information on the standard error stream (e.g., cerr in C++ or System.err in Java), and in fact as a requirement for this project, we will expect your program to produce such additional information as described below.

While the problem statement gives one sample input and its associated output, there are many more hidden test cases that kattis will use to evaluate your software. Please see the kattis website for a more complete explanation of the judging process and the possible outcomes that are reported. The challenge to the contest format is that if you're program fails for one of the given reasons, the system does not disclose any information about the test input that caused the failure.


Additional Examples

Because we know it can be very difficult to determine the reason for failure when you don't have many reference examples, we will be kind and provide a few additional test cases with known output, so that you might have something to trace when doing your software development.

additional cases: input, output


Required Trace Information

Although the official contest problem only demands that your program output the maximum number of happy viewers, we ask more of your own program. Your software must demonstrate the feasibility of the reported solution but describing which cats and dogs will remain on the show, and as a result, which viewers will remain happy.

Note Well: in order for your software to be accepted by kattis, it is imperative that the only information sent to standard output be the number of happy viewers. All other information that we are requesting must be sent to the standard error stream.

As an example of a format you might adopt, here is a plausible result for the original examples given in the problem description:

1                              <== sent to standard output
Keeping D1
Happy person: +D1,-C1

3                              <== sent to standard output
Keeping C1
Happy person: +C1,-D1
Happy person: +C1,-D1
Happy person: +C1,-D2

Please note that there may not be a unique optimal strategy. For example on the first case above, we could just as easily kept cat C1 and made the first viewer happy. So your strategy might not agree with what I report, but the number of happy people should agree. For additional examples, here is the trace output corresponding to the additional test cases we provided in the proceeding section.


Required Documentation

While no one reads your source code during a programming contest, we are using this as a course project and will be doing a code review. For this reason, you are expected to:


Submission Procedures

You are required to submit two files

Ensure that both files include your name in the headers, and then email them as attachments to the instructor.


Grading Rubric

The homework is worth up to 100 points, as follows:


Michael Goldwasser ©2016
CSCI 3100, Fall 2016
Last modified: Sunday, 13 November 2016
Course Home | Assignments | Schedule & Lecture Notes