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

h_alpha's blog

By h_alpha, history, 2 years ago, In English

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!

Full text and comments »

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