three way communication problem showing wrong answer

this code is running right on code,compile&run but showing wrong answer on submission … please can someone tell what is wrong in this…

  1. 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.

  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:


Read the second paragraph again.

condition is like this:

if( a <= R && b <= R) || (b <= R && c <= R) || (a <= R && c <= R )

print yes



Don’t do silly mistakes.
Keep practice…

still it is showing wrong ans
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.