and entering

LEAKED: CS124 Programming Problem

Given a list of office hours at various dhalls and the distances between each pair of dhalls, what is the shortest possible route that visits each dhall and returns to the origin dhall

After getting totally shafted at your Google interview, you decided to enroll in CS 124, Data Structures and Algorithms. But surprise, surprise, you are woefully unprepared! Now your only hope is to mooch pset answers off of your more knowledgeable classmates.

Luckily, you have N friends in the class. But don’t get your hopes up yet. Only M of your friends have the mathematical maturity to finish the pset, and only K of your friends can program in one of C, C++, Java, OCaml, or Python. You, of course, can do neither.

And it gets worse. Your “friends” are also awful communicators! They will ghost your texts, leave your Facebook messages on Read, and reply “lol sry just saw this” a week after the pset is due. You may begin to wonder if Lucy is really your friend at all, since she only talks to you when she needs to borrow your CVS ExtraCare Card. But that’s beside the point.

We can represent your social circle as a weighted directed graph. Each vertex is a friend, and the edge from friend x to friend y encodes how long it takes for y to respond to a message from x. For instance, the edge from you to Lucy has a weight of two weeks, since that’s how often she needs to borrow your fucking ExtraCare Card.

Your task is to figure out whether you can get a response  from 1 friend with mathematical maturity and 1 friend with programming skills before the next pset is due. You can either get a response directly, or by having a chain of better-connected friends ask on your behalf.


The first line contains three space-separated integers, N, M, and K.

The other lines contain a bunch of other numbers. You figure out what to do with them.


A last-minute Piazza post, frantically typed as tears fall onto your keyboard, desperately begging for any scrap of guidance to save you from the living hell brought about by your own incompetence, which will be promptly ignored all of your friends (especially Lucy).

© 2019