My Code is running correctly on my local machine as well as other IDE’s on sample test cases, but not on CodeChef.
Error is that my Code gives Wrong Answer
I can’t figure out what’s wrong with my code. I have tried to follow the approach mentioned in the Editorial.
#include <bits/stdc++.h>
using namespace std;
int main()
{
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
int test_cases; cin>>test_cases;
for (int i = 0; i < test_cases; ++i)
{
long int X1, Y1, R1, X2, Y2, R2;
cin>>X1>>Y1>>R1>>X2>>Y2>>R2;
if(X1==X2 && Y1==Y2)
{
if(R1>R2)
{ printf("YES\n");
printf("%f %f\n",double(X1+R1),double(Y1)); }
else
printf("NO\n");
}
else
{
//distance between centres of circles
double dis1=(X1-X2)*(X1-X2) + (Y1-Y2)*(Y1-Y2);
dis1=sqrt(dis1);
//finding the point farthest from circle 2 centre on circle 1
double y=Y1 - R1*(double(Y2-Y1)/dis1);
double x=X1 - R1*(double(X2-X1)/dis1);
//distance between the point found and circle2 center
double dis=(x-X2)*(x-X2) + (y-Y2)*(y-Y2);
if(dis>R2*R2)
{ printf("YES\n");
printf("%f %f\n",double(x),double(y)); }
else
printf("NO\n");
}
}
}