Hello USACO Guide Forum!

Here’s the problem I’m referring to: http://usaco.org/index.php?page=viewproblem2&cpid=1043

Uh, I pretty much have 0 idea of what to do? How am I supposed to approach this problem? I glanced over the editorial but it wasn’t very helpful on where to start, other than the fact this has some relationship with Permutations…

I don’t even know anymore: I’ve been stuck on this for 3 weeks now.

Best,

ShiftyBlock