15-295: Competition Programming and Problem Solving, Spring 2017

In this course you will learn the techniques and skills needed to solve algorithmic programming contests problems such as those that appear on the ACM ICPC, Codeforces, and Topcoder. Most of your time will be spent writing programs on your own to solve problems.

But the skills you will pick up from the course are far more valuable than just enabling you to win contests. Many of the algorithms and techniques are classic ones that every computer scientist should know. You will also learn to think about algorithms in a deeper way, because many of the problems require you have to devise a new algorithm, not just apply a classic one. These skills will be of great value in your other classes, in your job interviews, and in your future work.

Basic Information

Class Meetings: Wednesdays from 6:30-9:20pm, Wean Hall 5421

Instructor: Danny Sleator <sleator@cs.cmu.edu>, Office: Gates 8113, Phone: 412-268-7563

Google 15-295 Group: http://groups.google.com/group/15-295 (Required)

Codeforces 15-295 Group: http://codeforces.com/group/KIrM1Owd8u/contests (Required)

Name List: Put your names here (Required)

Grade Spreadsheet: Tabulation of Scores

For more information on how to join these groups see the Logistics section below.

Weekly Problem Sets

The weekly contests will take place on Codeforces. They are classified under a "Codeforces Group" called 15-295.

The point values of the problems for each weekly contest are tabulated below, along with a solutions page which is based on contributions from students and staff in the class.

295 Contests Page
#01 Jan 18, 2017: Point values: 1,1,2,2,3,3  Problems  Solutions
#02 Jan 25, 2017: Point values: 1,1,2,2,2,3  Problems  Solutions
#03 Feb 01, 2017: Point values: 1,1,1,2,3,4  Problems  Solutions
#04 Feb 08, 2017: Point values: 1,1,2,3,3,4  Problems 
#05 Feb 15, 2017: Point values: 1,1,1,2,2,2,2  Problems  Solutions
#06 Feb 22, 2017: Point values: 1,1,1,2,2,2,3  Problems 
#07 Mar 01, 2017: Point values: .5,1,1,2,2,2,2,3  Problems 
#08 Mar 08, 2017: Point values: 1,1,2,2,3,3  Problems  Solutions
#09 Mar 22, 2017: Point values: 1,1,1,2,2,2,3  Problems  Solutions
#10 Mar 29, 2017: Point values: 1,1,2,2,2,3  Problems  Solutions
#11 Apr 05, 2017: Point values: 1,1,1,2,2,2  Problems  Solutions
#12 Apr 12, 2017: Point values: 1,2,1,2,2,3  Problems  Solutions
#13 Apr 19, 2017: Point values: 1,1,2,2,3,3,0.5  Problems  Solutions
#14 Apr 26, 2017: Point values: 1,1,2,2,3,3  Problems  Solutions
#15 May 03, 2017: Point values: 1,1,1,1,1,1,1  Problems  Solutions


This course is 5 units. Each week you will be given several problems to try to solve during class. You will be allowed (for half credit) to solve these problems during the week after the contest ends. You can also get credit for solving problems during rated contests on Codeforces. (The site runs rated contests approximately every two weeks.)

Let me be more specific. Each problem that we give has some number of points between 1 and 3. Let X be the total number of points of the problems you solve in class. Let X' be the total number points of the problems you solve in the week after class. Let Y be the number of Codeforces problems you solve. (Y only counts problems solved during rated contests.) Your score in the course is X + X'/2 + Y.

Here is how your grade is determined:

score ≥ 25: A
score ≥ 15: B
score ≥ 10: C
score ≥   5: D

When you do a Codeforces rated contest, please email me that you have done it so that I can incorporate that into your grade. Each problem is one point.


You can make use of generic on-line resources while solving problems. These include things like language documentation, API documentation, algorithm descriptions, terminology, etc. You should not search for or make use of code written by others to solve the specific assigned problem.

If you're stuck on a problem, you are welcome to discuss it with another student in the class, or the course staff. Keep the level down so as not to disturb those around you.



A great way to get started and to improve is via the USACO training site. They've developed a series of lessons along with corresponding problems. It will take you from a beginner to a strong contest programmer.

There are a number of excellent tutorials on the algorithms and techniques needed to solve these kinds of contest programs on Topcoder's Data Science Tutorials web site.

You can also do old problems on codeforces. Just go to codeforces.com/contests and click "enter" on any of the contests. You can then try solving problems. You can also go to the scoreboard of the contest and click on other people's solutions to see their code. This is a great way to learn.

Feel free to contact (email or stop by) the instructor or the TA any time to discuss problems, including during class.

Here are a few tutorials about important algorithms:

A segment tree implementation and tutorial.
Lecture Notes about min cost flow, along with an implementaiton.
Union-Find Lecture Notes.
Range Trees (AKA Fenwick Trees)
Link-Cut Trees (See detailed comments in this codeforces submission.)

Being on an ACM ICPC Team

In the fall we form several teams of three (based on performance in qualifying contests). These teams then go to the ACM ECNA regional event. The best performing two or three teams are then invited to go to the World Finals in an exotic location. (At most one team from any given school is allowed to attend.)

Danny Sleator
Last modified: Mon May 8 22:44:15 2017