Map Solution is working fine, but unordered_map solution is giving wrong answer. Please help me.

Revision en1, by vishudon, 2022-05-03 20:32:16

Hi there,

I hope you all are doing well. I recently solved this problem: Problem Link

But while solving this problem, I faced a weird issue. Although, I am able to solve this problem using Map STL in C++, but same solution with unordered_map is not getting accepted. Not understanding why is this happening.

I thought to notice the time difference in execution after switching from map to unordered_map. But faced weird WA verdict. My unordered_map solution is giving WA verdict on test case 2 (on test input 3rd), But it is working fine on both my C++ editor and on online editors too on the same test case. This is STRANGE for me.

Solution 1 (using map STL): https://mirror.codeforces.com/contest/1598/submission/155784539 (Accepted)

Solution 2 (using unordered_map STL): https://mirror.codeforces.com/contest/1598/submission/155784670 (WA verdict)

Note: Solution2 is completely same as Solution1 except I changed map STL to unordered_map STL.

Now, I am not able to understand what is the issue with my code. Why am I getting WA verdict on test case 2 (on test input 3rd)?

Kindly help me in resolving and understanding this issue. Any help will be appreciated. Thanks in advance for your time and efforts. It means a lot to me.

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English vishudon 2022-05-03 20:32:16 1397 Initial revision (published)