Losing rating points in style

Revision en1, by usernameson, 2018-08-18 04:09:22

It was round 504. My first submission for problem D failed the pretests. I had 45 minutes to fix it. I figured out what was wrong with my approach fairly quickly but only found an alternate approach with roughly five minutes remaining in the contest. I coded as quickly as I could and submitted with 6 seconds to go in the contest. Unfortunately this solution also failed the pretests.

The reason my solution failed was I thought it would it be cool to write

for(int i=n-1; i; i--)

instead of

for(int i=n-1; i>=0; i--)

with the eventual goal of being a guy who writes stuff like

for(int i=n-1;i--;)

. Unfortunately

for(int i=n-1; i; i--)

terminates one step earlier than

for(int i=n-1; i>=0; i--)

, which is bad if you want to do stuff when i=0. So in conclusion it is probably not a good idea to experiment with new coding styles during a contest just because they look cool.

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English usernameson 2018-08-18 04:09:22 1027 Initial revision (published)