Пожалуйста, прочтите новое правило об ограничении использования AI-инструментов. ×

Блог пользователя kalidoss159

Автор kalidoss159, история, 4 года назад, По-английски

Contest : Educational Codeforces Round 86 (Rated for Div. 2), Problem — D (Multiple Testcases)

Codeforces submission: https://codeforces.me/contest/1342/submission/78251331

Other IDEs : https://ide.geeksforgeeks.org/eY2UpkI1FI, https://www.onlinegdb.com/B1QJjR7FL

I tried the same in my offline IDE as well. The output is just as expected. On the other hand, codeforces shows a different output. Any idea as to why this happens ?

  • Проголосовать: нравится
  • -5
  • Проголосовать: не нравится

»
4 года назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

When you do oMap.erase(it->first);, you're essentially erasing it. Then, you try to increment it, which causes undefined behavior. This can be tested by adding printing it->first every time you run the inner for loop. CodeForces and GeeksForGeeks will give different outputs.

Also, I don't think using a map to store values of m will make your code any faster, since the maximum values of n and k are the same. So using a map adds an unnecessary log n factor.