# 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

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

We were too getting WA with similar

[1].

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

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

6 Likes

4 Likes

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

@d_skyhawk In your case your formula to calculate it is wrong review it

1 Like

Can anyone tell the motivation behind this formula?

2 Likes

I understand the pain in this, but given ~600 teams solved the Q, I donâ€™t think any action will be taken at all.

It comes down to prior experience with double type answers and precision. I remember in one CF contest when a solution by Sumeet.Varma failed with 0.00001 error, which was totally because of him using Java. (same code in C++ passed)

Having said that, I donâ€™t think it was nice of them to give a Q with such brutal â€śabsolute errorâ€ť rather than â€śrelative errorâ€ť. In many ways, I liked last years problem set better But whats done is done!

12 Likes

they can at least give some partial credits to other solutions with the relative error of 0.0000001

@d_skyhawk
It might be because you are using â€śios_base::sync_with_stdio(false)â€ť. It disables the synchronization between the C and C++ standard streams. By default all the standard streams are syncronized, and after that you have used cin as well as printf, that might be the error in this case.

3 Likes

This years questions were not testing the skills but the knowledge of the language a person use, getting a WA just because of precision difference is unjust. Ranklist would have been a total stranger to the current Ranklist.

3 Likes

@ak_1andonly I do agree, just spent hours debugging code rather than solving problems.

1 Like

Ya this icpc tested our skills in programming language and math and not algorithms how does make sure the right teams are selected to regionals ,this needs to improve in forthcoming years and getting wa for not typing cout<<fixed;was annoying and losing a place in regionals because of that is even more annoying to say the truth this contest might have discouraged many debues in icpc even icpcsc @admin

2 Likes

Can someone please explain me how you derived that formula? Even after spending so much of time I couldnâ€™t figure it out? @d_skyhawk @vijju123 @swetankmodi @rishi_07

1 Like