Unordered_Map not working on CF Judge (GNU C++17)

Revision en1, by h_alpha, 2022-09-09 10:30:16

Hi Guys, I am trying to figure out the reason for the ambiguous behaviour of unordered_map on the CF Judge

The Question I am referring to is this 1728C - Digital Logarithm

Here are my submissions:

  1. Output where I am getting a wrong answer for Test Case 2, Subcase 1 (n=6) 171472454

  2. Output where I have printed the pairs for both maps (ma,mb) for Test Case 2, Subcase 1 (n=6) 171469543

  3. Submission which got accepted 171472328, using an ordered_map and no other changes

On my local machine (g++ (Ubuntu 11.2.0-19ubuntu1) 11.2.0) as well as OnlineGdb C++ 17 both of my submissions (1,2) print correct answers with their respective map values. =>Local Machine

But all the compilers on cf judge give out ambiguous answers for different cases under Test Set 2

  • GNU C++17 : 171472454 WA on Test Set 2 for n=6

  • GNU C++20 (64) : 171472566 WA on Test Set 2 for some other n whereas n=6 gives out the correct output

In the second part of the output we can see that only the first value is being updated in the map whereas the rest are just traversed even after being >=10 =>Cf Judge

Could anyone clarify the reasons for these anomalies:

  1. Why is unordered_map behaving ambiguously over different compilers on the cf judge

  2. Why does the unordered_map work on local and onlinegdb whereas not on cf judge even after keeping the compiler version same

  3. How does ordered_map pass all test cases on cf judge, is unordered_map not able to perform dynamic updates while traversing

Thanks in advance!

Tags unordered_map, map vs unordered_map, gnu c++ 17, gnu c++17 vs c++14, local, dynamic, map traverse, analysis of problem c

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English h_alpha 2022-09-09 10:30:16 1828 Initial revision (published)