Please read the new rule regarding the restriction on the use of AI tools. ×

Problem with C++ compilers of Codeforces

Revision en2, by xiaruize, 2024-09-22 17:46:46

I used random_device in order to generate a random number in this code.

On my own Windows, Ubuntu Virtual Machine and WSL, this code can generate different random numbers each time, but on Codeforces it generates the same number every time, so this gives people a way to hack your submission even if xor-hashing is in the formal editorial and the possibility of coincidence in hashing is nearly impossible.

I submitted the same code in C++20 and C++23, got Accepted. So I am wondering that is this problem only for C++17 or just nobody know the number of random_device in C++20 and C++23, so that they are not able to make a hack.

I suppose this problem should be fixed in order to avoid more solutions being hacked because of unawareness of a fixed 'random' number.

Or any other way to generate random numbers is suggested?

p.s. I tried $$$40000$$$ times on my PC and got all correct.

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English xiaruize 2024-09-22 17:46:46 66 (published)
en1 English xiaruize 2024-09-22 17:43:23 1074 Initial revision (saved to drafts)