External contests have been a part of Codechef for long now and Codechef should monitor the questions and other things before giving them rights to host on their platform. I was using the comments section to ask my doubts, but none of the organizers were active enough to reply. What made this contest even bad was the question The Segment Game had weak test cases, or maybe a wrong setter’s code. I asked them about it in the comments section but they simply ignored it, having messed up the Buggy Remote already, they preferred to stay silent on this one.
Codechef should focus on quality rather than quantity and having a small team of 2/3 will help to have better contests in the future. The test case on which a ac
(https://www.codechef.com/rankings/PWCR2019/bestsolution/PRWR1904,strivers) [The Segment Game ](https://www.codechef.com/PWCR2019/problems/PRWR1904) fails is
1
3
2 2
2 2
1 5
Its a request to Codechef to monitor such contests so that we have a better time.
Pre-store all the numbers which can be reached directly using the remote.
Now for every D in the query, Binary search for a number lesser than D and a number more than D.
Now there are three possibilities of reaching D from C.
You go directly to D from C using +
or - buttons, that will cost you
abs(D-C).
You go to the lower
number using keypad and one fire
button then from lower to D using +
buttons.
You go to the higher
number using keypad and one fire
button and then from higher to D
using - button.
The minimum cost of the above three will be the answer.
I think “each segment is distinguishable” has something to do with it, it could mean two things first that two similar segments like (2,2) and (2,2) are distinguishable or l and r are so set that no pair of (l,r) repeats itself and hence all segments are distinguishable.Now if we consider the second case, as each segment is distinguishable let us pick the segment with lowest r, so this segment can only lie inside segments which have equal r but all l values corresponding to these same r value will be different so if we are able to pick up the segment with highest l then you would never find another segment that would overlap or lie inside, hence Akash always wins. This is the most logical explanation I could find, I was expecting a TLE on my solution but when I got a runtime as low as 0.13, I reread the question and came to this conclusion as there were solutions with runtime as low as 0.04 too. So if this is correct then that means no case of (2,2) and (2,2) would ever exist and your friends solution is right.
For the test case I gave, some of my friend’s ac code gives the output as “Shivam” , whereas if Akash chooses 1,5, then Shivam will choose 2,2 and then Akash chooses 2,2. Hence Akash will win!