Hi, I wanted to share something weird that happened to me in the previous round.
After about an hour, I submitted this code for problem D: Submission 306394465
I knew the code had high memory and time complexity, but I was confident it would pass given the constraints. However, I received a Memory Limit Exceeded (MLE) verdict.
After the round, I resubmitted the exact same code using C++ 17, and it passed—with a huge difference in memory usage!
I just wanted to share this random incident and ask if anyone knows the reason behind it.
This happens because of the pointer troubles. In C++23, you receive 8 bytes for a pointer instead of 4 bytes in C++17.
Actually, the size of the pointer has nothing to do with the C++ version.
In 32 bit processors, pointers are 4 bytes (32 bits).
In 64 bit processors, pointers are 8 bytes (64 bits).
The MLE submission used C++23(GCC 14- 64, msys2).
The Accepted submission used C++17(GCC 7- 32).
Yep, you're right.
what are people's thoughts on codeforces only allowing c++23?
personally I don't want to think about what's the word size of the computer I'm submitting on, and how that affects the memory usage. Like I'm not interested in how hardware affects time/memory usage.
If codeforces only allowed c++23, it implies problem setter's code should run comfortable on 64-bit machines, implying time/memory limits should be set accordingly
Some code fails to compile on a newer C++ version because a new C++ version introduces identifiers that may conflict with user's code. It's hard to avoid this in Codeforces where
using namespace std;
is a must. (I'm stuck in C++20 becuase ofstd::print
.)My take is that Codeforces should provide options for different C++ versions and bitness (32/64) on the same compiler version. Theoretically it should be not too hard to do it once you have a stable environment for a specific compiler, because you just need to change the command line options (
-std=...
and-m32
/-m64
).(I think the bigger problem here is that it's apparently very hard for Codeforces to add a new compiler.)
Lots of other platforms, e.g. usaco.org, primarily use C++17. And also, why remove compilers? All that does is make people like us be more restricted. A better idea would be to only support 64 bit systems (whenever possible) for all the C++ versions.
https://codeforces.net/blog/entry/124741#comment-1107923
I even face troubles with C++20, so I prefer to stick with C++17.