ICPC P2045

Complete, but it doesn't run fast enough.
meh