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).
bufio
in Go to make your input faster. Default IO is pretty slow.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.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.
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 ofcnt
) isn't 32-bit on Codeforces but 64-bit on your machine?https://codeforces.me/contest/1598/submission/131508603
Pretty sure it was integer overflow, changing
cnt
touint64
rather thanint
worked.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.