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

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

In today's contest (Dytechlab 2022), a weird thing happened with me. I have submitted solution of second problem in C++14, but the result came wrong answer on pretest 2 but when the same code I have submitted in C++17 at the end of contest, all tests were passed. Due to this, my ranking was also effected.

Link of Wrong Solution: https://mirror.codeforces.com/contest/1737/submission/175033175 Link of Correct Solution: https://mirror.codeforces.com/contest/1737/submission/175033564

Can somebody tell me the difference between C++14 and C++17?

Thanks in advance.

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

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

Same with me. After the contest, someone told me it could be a compiler problem to cause sqrt not to work properly. I submitted the same codes with c++ 20 and c++17. 20 gave wa on test 4 and 17 passed.

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

Sqrt have some precision error. so it literally depends on compiler.

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

I got WA with one compiler, accepted with another

Most likely it has to do with 64-bit versus 32-bit. Also the widths of the various floating-point types vary. It's possible that in some circumstances your solution is actually correct. However, rely on this only if you know what you're doing.

Source: https://mirror.codeforces.com/blog/entry/107717