HCCoder's blog

By HCCoder, 13 months ago, translation, In English

Hi, Codeforces!

There have already been many posts about coding speed, but my problem is a bit different (although I do struggle with speed too). I often make very basic implementation mistakes.

Before I got into competitive programming, I was developing mobile games and apps. I had written thousands of lines of code and thought implementation was my strong suit. But in practice, contests have shown me the opposite — I keep losing rating purely due to bugs in my code.

For example, in the recent Codeforces Round 1022 (Div. 2), I spent 40 minutes on the second problem, then switched to the third one. I came up with the idea almost immediately after reading the statement, but I only solved it after five wrong submissions and a lot of wasted time. In the end, I earned just about 600 out of 1500 points. In all those submissions, the logic was nearly the same — the bugs were purely in the implementation.

This isn’t the first time I’ve lost rating because of clumsy coding.

What would you recommend? How can I practice writing code more carefully? Are there any resources or problem sets where the main challenge is implementation rather than thinking?

Can speedrun of an already solved problem help?

  • Vote: I like it
  • +17
  • Vote: I do not like it

»
13 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Auto comment: topic has been translated by HCCoder (original revision, translated revision, compare)

»
13 months ago, hide # |
Rev. 2  
Vote: I like it +1 Vote: I do not like it

I struggle with the same issue, the advice I was given was to try and solve more CSES problems and try to "speedrun" them. Another suggestion, if you encounter an issue like this during contest, is to try to create random test cases to try to find edge cases in your code; using a tool like CPH judge makes this much easier.

»
13 months ago, hide # |
Rev. 2  
Vote: I like it 0 Vote: I do not like it

same shit, after many times making the same mistake, i try to prove my code or give some kind of counter-tests

hope that i helped you:)

»
13 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

I'm curious. So you mean you have an easier time debugging actual software than CP code? Why is that? Is it because software code is usually more straightforward than CP code?

  • »
    »
    13 months ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    imo it depends on who wrote the software, but usually it is

  • »
    »
    13 months ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    Yes. For example, in cp if you write code that reaches the hundredth test and fails, then it is still wrong. But in the code of software there is no such thing, if there are bugs, then someone will write about it, then I will fix it.

»
13 months ago, hide # |
 
Vote: I like it +1 Vote: I do not like it

speedrunning already solved problems can help reinforce clean bug free implementation.Also try solving implementation tagged problems on Codeforces to build muscle memory and precision.Overtime this will reduce careless mistakes in contests.

»
13 months ago, hide # |
 
Vote: I like it +3 Vote: I do not like it

Implementation in CP can't really be taught, you just acquire it as you go. Some tips that I can probably give you is:

  1. Do problems with the implementation tags, or solved problems that you remembered that you struggled with implementation. Problems from Codeforces are usually not very implementation-based, so you may have to seek another source (ICPC, OI contests, etc)
  2. Try to find a coding pattern that works for you.
  3. Write a stress tester, it's a 10 minutes investment, so a good investment if you think you will be staying at that problem a bit longer.
  4. Try thinking a bit more before touching your keyboard. Is your idea of the solution clear, or is it still fuzzy?