Got 70 but not 30 in ELOMAX During Contest

Problem-Click Here
Solution-Click Here

During August Lunchtime 2020,I got 70 Points didn’t get 30 Points.
Can Anybody Point out what was wrong in my code?
Thanks in Advance!

Also, I wanted to know, what is the approach you followed to calculate the ratings? I am stuck at that.

I calculated by adding Row wise for every player and then calculated the maximum.

@admin Can You Please tell was this a Codechef Bug that i didn’t get 30 points ?

Your AC code Link
The mistake u made is in the comparator function. Remove the equality and u will not get TLE. :slight_smile:

3 Likes

Thank You So much @unsung_heroes .
But what is the reason of getting TLE if i am considering equality sign in comparator function?

When i made another Submission, i got Runtime Error Instead Of TLE.
My Submission getting RE During Contest-Click Here

That equality sign is the reason for this too? and if yes then what’s the harm in adding equality sign?

There is one CF blog, i dont have the link right now, it says multiple times to never use equality in sort comparator. I dont know the actual reason, maybe it is that the function ends up having many comparisons leading to the TLE or RE(maybe)

1 Like

But if we add/remove equality sign, i dont think no. of comparisons will increase/decrease.
Moreover, My code is Running well for Second Subtask, which have larger Constraints.

@zephxr After searching for 1 hour, i finally found the blog-Link. Hope after reading the blog, you would never make this mistake. Another Link

1 Like

And if you actually want to know the reason , this blog-Link :stuck_out_tongue:
“In C++, comparator should return false if its arguments are equal.”

1 Like

I will never forget This Line Now:

In C++, comparator should return false if its arguments are equal.

Thank You So Much @unsung_heroes. Today i learned Something new.

2 Likes

Thanks For this.

1 Like

Can you pls help me @zephxr? I could not score anything in this problem. Can’t figure out my logical problem.
Here is the link with my logic and answer.

when is the editorial going to arrive. Or its out already?

@debadri16 Why are you sorting the matrix column wise(To calculate Rank, Right?) we should to sort the matrix row-wise as our in our input Rows are represented by players and columns are represented by months.

No its not out yet!

I wrote wrong. I am sorting row-wise for each month(column). you can see in my solution.

You are sorting whole matrix at once!
Try to take all the elements of all rows column wise in a vector and then sort that vector and then calculate rank of each player.(Thats how i did and that is easy )

I think there’s a problem in your sorting of matrix.

Same thing bro, I tried. The problem is somewhere else. Can’t figure out :confused: