Dmohan's blog

By Dmohan, history, 3 years ago, In English

Hello Codeforces community,

I have been using Golang of late for upsolving problems on Codeforces. I have experienced that for a handful number of contests that even for the best code written on Golang for certain problems, I'd run into TLE while the same logic seem to work fine for other languages(ex: Python, Java) which are below Golang in terms of performance. I am not sure if this is because that i am unrated (and because of that the environment set for unrated is not on par with that of rated users) or if its because the current Golang version is a bit old. Assuming the latter as one of the cause, i would like to request the Codeforces management to upgrade the current version of Golang. If its the former, then please upgrade the go environment(i dont know.. Memory/Heap space perhaps?).

Imagine using Golang as your coding language while participating in a serious contest and running into TLE for a 800 problem and being clueless about why that happens and later you found out that a seemingly terrible logic on a different language (way inferior that Go in terms of performance) seem to work just fine. This scenario would mean that its a waste of time and effort and its doesnt encourage the user to use Go on codeforces or to compete for that matter. I presume the people using Golang as the go-to language for programming on Codeforces is a minority and would request them to support and voice if its a concern.

Thanks, Dmohan (unrated).

  • Vote: I like it
  • -2
  • Vote: I do not like it

| Write comment?
»
3 years ago, # |
  Vote: I like it +14 Vote: I do not like it
  1. You should use bufio in Go to make your input faster. Default IO is pretty slow.
  2. CF uses 32-bit x86 machines, which might be the reason behind some of the performance hit.
  3. I am not sure if this is because that i am unrated (and because of that the environment set for unrated is not on par with that of rated users): maybe, not sure.
  • »
    »
    3 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Here is exactly the same solution in go (WA#8) and python (OK). It's an interesting thing because IMHO there is no integer overflow but go-solution gets wa (maybe I'm wrong?). I've created test input with 1e5 zeros and 1e5 ones (my guess is test case #8 is something like that) and both solution print correct 10000000000 locally. I haven't yet figured out why this is so.

    • »
      »
      »
      3 years ago, # ^ |
        Vote: I like it +8 Vote: I do not like it

      It's wrong by exactly 2 * 2^32, which really makes the whole thing smell like integer overflow. Are you sure it isn't the case that int (the type of cnt) isn't 32-bit on Codeforces but 64-bit on your machine?

    • »
      »
      »
      3 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      https://codeforces.net/contest/1598/submission/131508603

      Pretty sure it was integer overflow, changing cnt to uint64 rather than int worked.

»
3 years ago, # |
  Vote: I like it +1 Vote: I do not like it

It would be nice to see the Go and Rust versions updated TBH, I've had a few compile errors recently when trying to use newer language features.