# 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.

12 Likes

Simple.

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 :/.

3 Likes

Here I used setprecision(10)

4 Likes

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.

6 Likes

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

8 Likes

5 Likes

@admin I think, there is some issue with testerâ€™s solution.

4 Likes

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

``````
[1].

[1]: https://ideone.com/k7slv4``````
6 Likes

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!!!

6 Likes

4 Likes

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

3 Likes

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

2 Likes

@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.