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

12 Likes

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

3 Likes

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

Here I used setprecision(10)

alt text

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.

@admin Please look into the matter

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 :confused:

8 Likes

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

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

@admin please do something for this

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.