To solve this problem, my advise is:
1. Think about what the problem really is about. It took me about 2 years to get the right idea (but I might not be one of the brightest in this department).
2. Once you have the idea, try to implement it. In principle you could cram the lot in a few recursive functions, but my advise is to solve it step by step, wasting lots of memory to store intermediate results, and lots of cycles to generate and print debugging information.
3. Once you got it running you'll most likely get WA because you overlooked some details and/or made some tiny implementation errors. Hunt for the original test data (it's somewhere on a Swedish site, along with the authors' solution and a description of the method in Swedish).
4. Debug your code on an almost case-to-case basis. Expect to make lots of debugging cycles; by solving one problem you might introduce wrong answers for cases that previously were correct for the wrong reason. Some basic drawing skills come in very handy in this phase (if you understand the problem, it is a lot easier to hand-calculate the answer from the drawing, than it is to make your code give the same answer).
5. If you got your code accepted by now, that's great. If not, wait a few months and start all over at step 1. Or you can consider giving up all together and find another nice hobby, like bird watching or stamp collecting (or shoveling snow, if you are in a Nordic country).
Anyways Per: a very, very nice problem, really. But did you truly expect anyone to solve it in the course of a single contest?