Someone Please explain the difference between these two solutions for Compression Algorithm

These are my two solutions for the question Compression Algorithm.

I cannot understand the difference between the 2 solutions.
Note: THe expected precision was 10^-6.
alt text


In case answer is like-

1.00000589999, then %6lf prints 1.000006 while %8lf prints 1.00000590000. Seems ok right? But what if expected answer was something like, 1.0000048, and you are getting “000055” ? Its rounded upto “0.000060” Meaning its a case where {10}^{-7}th digit made a difference. Usually, they shouldnt ask THIS close precision, and if asking then their should be checking based on relative error [like happens on CF] instead of absolute. People cant control language’s mechanics :/.


Okay @vijju123 then what about this one. This gives WA too.

Here I used setprecision(10)

alt text


I am not completely sure when we go this deep into decimals dear, I am sorry for that :(. But the reason you got WA is realted to absoute value being used, being rutheless ({10}^{-6} doesnt make sense to me since correct algo gives very near answers). I also feel that relative error should ahd been considered.

@admin Please look into the matter


Same here mate, my c++ code gave me a WA and the same code in python gave me AC. I kind of experienced this before so I quickly used python without wasting time. I still don’t know why c++ does this to us :confused:


@admin This is a serious issue. Please look into the matter.


@admin I think, there is some issue with tester’s solution.


No, there’s either an issue with the judge (a bug) or it’s a feature (they’re checking absolute error and not relative error)

We were too getting WA with similar



They intentionally checked absolute error, and trust me things get dicey when you aim for this high precision. Usually people tolerate an absolute error of 0.01, or relative error of {10}^{-6}, which make sense to me. Absolute error of {10}^{-6} was really, well, rutheless.

@admin pls look into the matter…hoping for a resolution or an explanation of what went wrong!!!


@admin please do something for this


Yeah i said it might be a bug or even a feature. I’ve experienced this 5-6 times so I knew they wanted me to use python xD or play with c++ mechanics to get the correct result (exact)

1 Like

Even I used round off function in python and got wrong answer even for precision upto 7 places because it was rounding off. This must be looked into @admin


@swetankmodi but we used setprecision(10) still WA.


@rishi_07 I used setprecision 18 Still WA.

WA in python? Mind sharing your code if it’s allowed to?

I think 7 should give AC as well. Can anyone confirm?

@vijju123 Kindly check the photo posted by d_skyhawk in comment section. There upto 10 precision was used. Leave all of that aside, this is not the first time we are solving this type of precision related questions. 0.6lf works everywhere where 10^-6 precision is needed. I don’t understand why it failed here.