Learning, the hard way

kompareToday I finished debugging a problem called “ro” that was proposed at an earlier round of .Campion. The screenshot shows the only change in the source code that, applied, would have brought me 100 points instead of 20.

Things learnt:

  • If anything can go wrong, it will.
  • If anything just cannot go wrong, it will anyway.

Now, more seriously:

  • Always, and I mean always make a backtracking, fail-safe solution and test the results for some small test case.
  • If you’re getting lost in that ugly 500+ line program, better start from scratch than trying to patch it.

For the reference, here’s the quick’n’dirty bash script I used to test my solution after correcting it:

for i in `seq 1 20`; do echo “test $i” && cp $i-ro.in ro.in && time ./minchange.e && head -n 1 ro.out > ro.out1 && head -n 1 $i-ro.ok > $i-ro.ok1 && diff ro.out1 $i-ro.ok1 && rm ro.out1 $i-ro.ok1 || break; done

minchange.e is the program executable name, located in the current directory.

5 Responses to Learning, the hard way

  1. I’m sorry for that.. I know such kind of feeling (Farewell, BOI 2006!!). It’s really unpleasant to know that you SOLVED the problem, but the result you worked so hard for is totally unsatisfying… Well .Campion isn’t the most important contest of this year! It’s important for you to succeed at National Olympiad in Informatics and further! [And I know you will!]

  2. I have again written ambiguously. From what I said, it would somehow result that you didn’t do very well at .Campion, which is certainly false. You are in the top with a good score at a tough contest like .Campion! That’s great!
    Good luck!

  3. Constantin says:

    No ambiguity at all (I’ve installed a new compiler :P )

    EDIT: I’ve come across some C++ warnings containing the word “ambiguous” ;)

  4. Sergey says:

    Heh, the minimal-change problem eh? :) In case you still like it, there’s a fun variation on it over at net-force (really decent challenge site):this one.
    Also, good luck with the MIT app, we’re in the same boat on that one ;)

  5. Constantin says:

    Hey that’s cool, I’ll have to try it out.
    Good luck to you too!

%d bloggers like this: