fkndonttrespass's blog

By fkndonttrespass, history, 2 months ago, In English

https://codeforces.com/contest/1737/submission/175037592 https://codeforces.com/contest/1737/submission/175037480 https://codeforces.com/contest/1737/submission/175037412

These three exactly same codes when submitted in GNU C++ 14 or 20 give wrong answers on test 4 and when submitted in GNU C++ 17 gives wrong answer on test 11, although they seem to work perfectly on my system, any clue why is it so? (p.s. failed system tests. :') )

 
 
 
 
  • Vote: I like it
  • +1
  • Vote: I do not like it

»
2 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Auto comment: topic has been updated by fkndonttrespass (previous revision, new revision, compare).

»
2 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Same issue. My B was passed in pretest and WA in tc 11 system test with c++17. AC with sqrtl instead of sqrt.

»
2 months ago, # |
  Vote: I like it 0 Vote: I do not like it

I faced the same issue during contest. So I had to write a sqrt() function of my own assuming sqrt() in C++ stl is not right. This code gets AC with sqrt() function in other GNU C++ . Apparently, for some reason sqrt() is returning the ceil value in some cases.

»
2 months ago, # |
Rev. 2   Vote: I like it -9 Vote: I do not like it

Because sqrt() is double function and since both double and long long has 8 bytes, it won't be able to convert to long long precisely.

»
2 months ago, # |
Rev. 2   Vote: I like it +3 Vote: I do not like it

That's why I switched to C++20.

Getting WA on pretest X is better FSTs.

C++20 is more precise in my opinion

»
2 months ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

change sqrt to sqrt because the input is long long

Ac c++14 : 175143762, Ac c++17 : 175144031, Ac c++20 : 175144158

I just change the sqrt to sqrtl