UEM KOLKATA. Strange case

General mistakes in this types of questions are:

  1. **Using wrong data type** , for instance here Xi and Yi lies in [ -104 , 104 ]. It is quite obvious that Xi2 and Yi2 will lie in [ 0 , (104)2 ]   i.e. [ 0 , (10)8 ]   now this value can't be hold in an int datatype hence is to be stored in **long int** or **long long int** .
  2. **Wrong output format** , since codechef only gives WA or AC for a compiled solution ( neglect runtime error ) , users often mistake wrong output format with WA. for instance, here in this question out was supposed to be print in one line for each test case regardless of the number of cars but of the availability of the cars. but some of users were printing availability for every cars.
Hope it helps !

Thanks :smiley:

EDIT 1:
Just make Xi and Yi of type int and you will get AC.

Reason:
After observing the pattern of wrong answer I realised that somehow the author of the question had made some mistake while setting testcases. The values of Xi and Yi are given in the range of long long or long but user he has set data accoring to int eg. (100000)2 when taken in int gives a negative value but when taken in long long gives positive value and this whole thing is generating wrong output.

Problem link : https://www.codechef.com/problems/UEMP01

Solutions with different combinations of data types and their verdicts : https://www.codechef.com/status/UEMP01,radeonguy

1 Like

My this solution was judged as incorrect CodeChef: Practical coding for everyone
Don’t know why. @sdssudhu could you point out the mistake.

Hell mannn…
if we are taking square root of (x^2 + y^2) and comparing it with radius(k)… then it is giving WA verdict
but if we do compare (x^2+y^2) with square of radius (k^2)… it is giving AC verdict…

CodeChef: Practical coding for everyone for this i get WA verdict…
CodeChef: Practical coding for everyone for this i get AC verdict…

the difference is… in the 1st submission, i’ve done comparison sqrt(xx+yy) <= k …
in the 2nd submission, i’ve done comparison (xx+yy) <= (k*k)…

@kishore1 This is due to the inacurracy of results returned by the sqrt function for large inputs.For eg if the input is large and the sqrt function returns the value 10000.0001(inaccurate value) instead of 10000.0000(actual result) and the radius is 10000 then your program will output “Not Available” instead of “Available”.

I think something is wrong with the testcases. The constraints mention that coordinate values are between -10^4 to 10^4 but it is probably not followed. The author might have added the testcases where Xi is around 10^5 or greater and generated the output for those testcases using int data type. This explains why long long int in C++ fails. Similar case with the languages supporting big integer.

2 Likes

I got it… so, i shared…
thanks for ur comment… @utkarshg_1998

Even I faced the same problem…It was a formula based question and I used long long just to be safe but I got WA…

I did it with the data type “long int” which is enough… but still got WA verdict… so, apparently what you said is not the reason behind so many wrong verdicts though the solutions are correct… @sdssudhu

make everything int instead of long long int and try resubmitting again

May be it would get accepted then.But there is hardly any mistake in my solution.Our solutions are judged incorrectly.

1 Like

Not hardly … there is no mistake, your solution is totally fine. Test cases are bad. Input was not according to the given constraints.

1 Like

why using int instead of long long int will give AC ? This will reduce the time but can never be a logic behind getting AC.

It prints only one time in one testcase. Please see the code carefully.

int can easily store 10^8.However I used long long int just to be on safe side and why it will give wrong answer if I use long long instead of int ? using int can only decrease the execution time and can never be a logic for getting AC where long long int is giving wrong.

FYI try this after including limits.h

cout<<INT_MIN<<" "<<INT_MAX<<endl;

output: -2147483648 2147483647

int can easily store 10^8.

Anyway , I used long long int but that too gave wrong answer.

1 Like

You didn’t read the whole answer did you? or maybe I was not clear on my part.
Testcases were not correct, here output was according to int and somehow author has inserted 106 as the value of Xi which overflowed int and long int but not long long int.

TL:DR version : declare every variable with int or long int and you will get your answer accepted although logically it will be wrong but according to testcases it will be right.

1 Like

wrong testcases, that is why!

P.S. I have actually did that

Solutions with different combinations of data types and their verdicts : CodeChef: Practical coding for everyone

1 Like

Range of int I think is not upto 10^8 . I used long and I got AC . So using long long can give a WA only if int does not support upto 10^8 as long long easily can support 10^8.

yeah, because the setter wrote program using int and put test cases which were long long int.