There is some small mistake in my code. Help will be appreciated.

I have first applied the transformation (x,y) goes to (x-y,x+y) . This rotates the plane anticlockwise by 45 deg. This also scales the grid so that the multiplication by sqrt(2) is not needed at the end.

Then I sort first using the first coordinate and find the minimum difference and do the same for the second coordinate. Half of the minimum of these two is the answer.

# Help me Debug WTBTR

**udayan14**#1

**c_007**#3

Just add the line :- cout.precision(30)

before printing the answer

The link to the modified code :- https://ideone.com/nZ2J2f

**udayan14**#4

That was it. I feel silly getting the logic right and then not printing the solution correctly

I think setting precision to 30 is not a good idea just use this instead

cout << fixed;

**udayan14**#8

Why is it better than setting precision to 30 @samarthtandon? Also I am sorting along the x and y co-ordinates separately.

**tanmax**#10

I am also using the same approach but why does it show time limit exceeded when i am just using a sorting.

#include<bits/stdc++.h>

using namespace std;

int main()

{

int tc;

cin>>tc;

//int flag=0;

while(tc–)

{

int n;

cin>>n;

//node arr[n];

long double d1[n],d2[n];

for(int i=0;i<n;i++)

{

long double x;

long double y;

cin>>x>>y;

d1[i]=y-x;

d2[i]=y+x;

}

```
sort(d1,d1+n);
sort(d2,d2+n);
long double min1=d1[1]-d1[0];
long double min2=d2[1]-d2[0];
for(int i=0;i<n-1;i++)
{
if(d1[i+1]-d1[i]<min1)min1=d1[i+1]-d1[i];
if(d2[i+1]-d2[i]<min2)min2=d2[i+1]-d2[i];
}
min1=min(min1,min2)/2;
cout.precision(30);
cout<<min1<<endl;
}
```

}

Help will be highly appreciated.

**karangreat234**#15

The min() function is only used to compare 2-integers, don’t use it, compare the numbers by yourself , using greater than condition

**karangreat234**#18

Oops, I saw your code which had WA in big test-cases,in actual-contest, so thought you should get AC in those cases first, then remove TLE, ALWAYS USE FASTI IO