So I was solving this problem https://mirror.codeforces.com/gym/105723/problem/F
and wrote this solution https://ideone.com/SNfGJ6
It works fine in my laptop and ideone C++ 14 but when I submitted it in C++17 (GCC 7-32) I got WA on test 1. It did not make sense to me how I got a vastly different result on the test case in my laptop and CF. I suspected some type of RTE but I could not find any. Then I just submitted in C++23 (GCC 14-64, msys2) and got AC even though I did not change anything in the code.
Anyone knows why this happened. I feel like knowing it would kind of help me avoid it in contests. idk -_-








I suspect this has something to do with floating point precision error. G++23 has a 64 bit judge, therefore the floats are more accurately represented. Try to avoid floats as much as possible if you can
I also suspected something similar but it got the right answer in C++14 on ideone, which was 261798.698746. But C++17 on CF got me 361929.351562. It's insane how much the precision error blew up if that's the case.
The thing is that with c++17 you get inside the
if (rt > rb)but with c++20 you don'tComparing doubles with some eps value could help probably
Damn how did i miss that. I added precision handling on the if(len <= ab) statement later but completely forgot about the other if statement. Thanks