#include
#include <math.h>
#include
using namespace std;
int temp[100001] , temp2[100001];
void mergeSort(int x[],int y[],int low,int mid,int high){
int i,m,k,l;
l=low;
i=low;
m=mid+1;
while((l<=mid)&&(m<=high)){
if(x[l] < x[m]){
temp[i]=x[l];
temp2[i]=y[l];
l++;
}
else if (x[l] > x[m]){
temp[i]=x[m];
temp2[i]=y[m];
m++;
}
else if(x[l] == x[m])
{
if(y[l] >= y[m])
{
temp[i]=x[l];
temp2[i]=y[l];
l++;
}
else
{
temp[i]=x[m];
temp2[i]=y[m];
m++;
}
}
i++;
}
if(l>mid){
for(k=m;k<=high;k++){
temp[i]=x[k];
temp2[i]=y[k];
i++;
}
}
else{
for(k=l;k<=mid;k++){
temp[i]=x[k];
temp2[i]=y[k];
i++;
}
}
for(k=low;k<=high;k++){
x[k]=temp[k];
y[k]= temp2[k];
}
}
void partition(int x[],int y[],int low,int high){
int mid;
if(low<high){
mid=(low+high)/2;
partition(x,y,low,mid);
partition(x,y,mid+1,high);
mergeSort(x,y,low,mid,high);
}
}
int x[100001] , y[100001] ;
int main() {
int t , n ;
scanf("%d",&t);
while(t--)
{
printf("\n");
scanf("%d",&n);
for(int i=0 ; i<n ; i++)
{
scanf("%d %d",&x[i],&y[i]);
}
partition(x,y,0,n-1);
/*for(int i=0 ; i<n ; i++)
{
printf("%d %d\n",x[i],y[i]);
}*/
float dist = 0;
for(int i=1 ; i<n ; i++)
{
dist += sqrt( pow(x[i]-x[i-1],2) + pow(y[i]-y[i-1],2) );
}
printf("%.2f\n",dist);
}
return 0;
}
Each test case is running fine … wats the problem ???