I'd like to understand the algorithm that solves [Google Code Jam, Tutorial, Problem C](http://code.google.com/codejam/contest/dashboard?c=32004#s=p2). So far I wrote [my own basic implementation](https://github.com/ripper234/Basic/blob/master/java/src/main/java/org/basic/google/codejam/practicecontest/ProblemCSolver.java) that solves the small problem. I find that it's unable to deal with the large problem (complexity O(min(n, 2\*k)! which is 30! in the larger data set).

I found this [solution page](http://code.google.com/codejam/contest/scoreboard?c=32004#vf=1), but the solutions are of course not documented (there's a time limit to the context). I saw that at least one of the solutions used the [Union Find data structure](http://en.wikipedia.org/wiki/Disjoint-set_data_structure), but I don't understand how it's applied here.

Does anyone know of a page with the algorithms that solve these problems, not just code?