this code is running right on code,compile&run but showing wrong answer on submission … please can someone tell what is wrong in this…
-
The problem statement specifies that communication may take place via a middle person, whereas you are not accounting for that fact.
Eg: Consider three people standing in a straight line, at coordinates (0,0), (1,0), (2,0), and maximum distance over which communication can take place is 1. According to your code, the answer will be no, even though person 1 and 3 may communicate via person 2. -
The distance formula should have a ‘+’ sign in the middle, not a minus. According to your code, the distance between point (1, 1) and (0, 0) would be 0, which is clearly incorrect.
hello deeksha_garg ,
Seeing your solution i think you don’t check your code carefully.
In distance finding formula there is ‘+’ sign between the formula not ‘-’ sign.
correct code:
a=(x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);
b=(x2-x3)*(x2-x3)+(y2-y3)*(y2-y3);
c=(x3-x1)*(x3-x1)+(y3-y1)*(y3-y1);
Read the second paragraph again.
condition is like this:
if( a <= R && b <= R) || (b <= R && c <= R) || (a <= R && c <= R )
print yes
else
no
Don’t do silly mistakes.
Keep practice…
still it is showing wrong ans
https://www.codechef.com/viewsolution/8264269
please tell now which mistake i m doing
instead of comparing a,b,c with r, compare with r*r because in your solution a,b,c are squares of distance.