Doubt in CSES' Inversion Probability after addition of new test cases

Revision en1, by AT_80, 2023-06-19 22:22:43

Recently, CSES updated the test cases of its problem Inversion Probability. This resulted in a large number of previously Accepted solutions getting a WA on one or more of the new cases.

My submission too was part of this. In particular, even after revision and rechecking from my side, it passes all but one of the 19 tests.
Here is the code:

Code

The test case on which it is giving a wrong answer is:

Input
Expected Output as per CSES
Output by my code

This, at least to me, seems like a scenario where my logic is certainly correct, but perhaps my implementation, or my understanding of how rounding of decimal point numbers in C++ works, is flawed.
And judging by the drop in the number of correct submissions after the addition of these new cases (was over 900 earlier, if I remember correctly, but is now at about 160), there definitely appears to be a catch in these new additions.

I tried the abovementined test case locally, and even at a 12 decimal point precision, the output was 53.418336500000
This only further perplxes me about where I am going wrong, as the question clearly mentions that half is to be rounded to even.
I would thus be really grateful if someone could explain what this is all about, and additionally, also advise me on how to correct my code.

Tags cses, math

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English AT_80 2023-06-19 22:22:43 3298 Initial revision (published)