# UEM KOLKATA. Strange case

Problem

WA solution

AC solution

where is this wrong ?

Same here.
I also had the same logic but it gave me WA everytime!!!

it gives WA for all solutions in python inspite of correct here,can anybody explain why?

https://www.codechef.com/viewsolution/10842050

Yeah, itâ€™s very strange! I also gave the same solution in C++. And every time it gave WA. At last my partner tried it in JAVA and it worked! Probably, the contest was a bit language biased.

same problem facedâ€¦

Exactly faced the same problem.Its very sad and frustrating,when you submit with full confidence and get WA,and after viewing same kind of AC solutions, frustration increases more.Really, time-wasting. Codechef must take some action to prevent such kind of fuss.@admin @dpraveen

yupâ€¦ faced the same problemâ€¦
Indeed its a contest for high school studentsâ€¦
itâ€™s not meant for computer science students at allâ€¦
That tooâ€¦ somany mistakes in framing the problem statements exactlyâ€¦
fedup with thisâ€¦
And waste of time for 2 hrs unnecessarilyâ€¦

(-1,-5) did not even satisfy the radius 5. Terrible competition.

Somebody please explain why this happened.

It is so strange.

What is wrong in this solution?

1 Like

your solution prints available or non available after it encounters each pair of co=ordinates. The problem statement asked to check for availability from a set of co-ordinates.

1 Like

I faced the same problem in java, same logic but only got WA

The reason is overflow happens in int while it does not in long long int. As the value of x and y are in the range of 10^4 x^2=10^8 which does not fit in int but does in long long . I believe the test cases have been given keeping the values of x and y and probably k as int or long hence the solution with int passed while the one with long long did not .
However this is just my assumption and there could be some other reason also.
Upvote and accept my answer if you find it to be correct.

2 Likes

yeahâ€¦ u r rytâ€¦ but long int is enough for that which could hold upto 10^9 @sdssudhu

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

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.

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 https://www.codechef.com/viewsolution/10840760
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â€¦

https://www.codechef.com/viewsolution/10845181 for this i get WA verdictâ€¦
https://www.codechef.com/viewsolution/10845228 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