Thursday, November 17, 2011

SRM 524: ouch

Well, here is what happened. I first opened the 500 , and although I reached some useful conclusions , like that you should be able to do binary search and that the maximum result is likely not larger than 2000, I didn't do much.

I noticed that 250 was probably very easy because of the large scores. I open it and...

Given a number, you subtract any positive, non-prime value out of it until you reach 0, return the minimum number of subtractions.

I began coding the standard prime check. Then it occured to me that if we find n is prime then we can subtract 1 else we subtract n. And then you can recurse and solve (n-1). I was about to compile that code, when I noticed that if it is prime we can just return 2.

Compiled, submitted. And of course right then I noticed that such lame logic does not work for number 3.

I fixed it and I already had a low score. My only hope was the challenge phase.

I prepared to open the median rated coder's solution. He had 242 points so I was pretty sure he missed the 3 case.

The challenge phase starts and I clicked the source VERY FAST. Of course, it turns out he missed the n=3 case. I was ready to challenge but then: The challenge button was missing. Yes, apparently there is a race condition that allows you to open source codes before the window receives the notion that you can challenge. So, if you open a source code in that milisecond, the window won't show the challenge button!

Once I noticed, it was too late, I closed the source, opened again and the challenge button was there, but the solution was already challenged.

I made a mistake then, I said that maybe there is still hope if I challenge another solution very fast, so I rushed to open something else, I didn't see any 3, but didn't pay too much attention to the source code, it turns out that it was fine.

After that I was just mad about the arena glitch that ruined my rating and decided that if my rating was going to die today because of some freak arena glitch, I'd rather also keep my volatility high. So I started doing random test cases. Was also interested to see if the apparently topsort solutions for the 500 in my room were correct, so I tried random challenges on them. Seems they are ok.

No comments :