Alvaro wrote: Dudi Hatotah wrote:
Shouldn't this code work slowly due to using list[i] instead of using a pointer to the list?...
It seems to be one of the best codes, so I wonder how can it work so fast...
If list were a pointer to int, list[i] would just be *(list+i). The processor has addressing modes that do that as fast as you can dereference a pointer. The fact that list is a vector doesn't change things much, since the address of the first element of the vector won't change, so the optimizer can load it in a register. And of course, the call to operator is inlined.
Thanks. I guess the optimizer optimizes much better than I thought.
For some reason, though, loops in which I used list.end() instead of a variable which keeps the list end's address were many times slower. That's weird. list.end() should be fast, and with all those optimizations, I find it odd.
How come there were 11 entries for this contest when the last "News" item was written on the main page of cpp-home (which was before I submitted), and now there are only 10? How is that possible?...
You had to get the right answers to get a medal... There ended up being more than 11.
Oops, I looked at the medals instead of the actual checkings...
There were 12 participants, in the end.
There were only 2 participants on contest 34, then 4 on contest 35... now we're at 12!
Things are looking good!
Guest wrote:I'm surprised there were problems with determining a winner. If each of the code was run a few thousand time and the minimum of all those times taken a reasonable ranking should have been found. Isn't the minimum time out of all those test cases all we care about?
Since all the "gold medal" codes were similiar, there is a very minor difference between them. None of them was better than the others significantly.
Thus, if a winner will be determained it will only be due to luck (I consider making the right micro-optimizations for the right compiler and system luck).
Since this contest should be (IMHO) about skill and not about luck, there is no point in determaining the winner in such a way.