#include <stdio.h>
#include <memory.h>
#include <math.h>
const int maxn = 3100;
double x[2*maxn], y[2*maxn];
int n, m;
double r[maxn];
int p[maxn];
bool w[maxn];
inline double sqr(double x)
{
return x*x;
}
inline double dist(int i, int j)
{
return sqrt(sqr
(x
[i
]-x
[j
])+sqr
(y
[i
]-y
[j
]));
}
inline double cos_angle(int i, int j, int k, double a, double b)
{
return ((x[i]-x[j])*(x[i]-x[k])+(y[i]-y[j])*(y[i]-y[k]))/a/b;
}
inline bool optimize(int i, int j, int k)
{
double a = dist(i, j);
double b = dist(j, k);
double c = dist(k, i);
double aa = cos_angle(i, j, k, a, c);
double bb = cos_angle(j, k, i, b, a);
double cc = cos_angle(k, i, j, c, b);
if (aa <= -0.5 || bb <= -0.5 || cc <= -0.5)
return false;
double p, q;
p =
(x
[i
]+x
[j
])/
2 +
(y
[j
]-y
[i
])*
sqrt(3.
0)/
2;
q =
(y
[i
]+y
[j
])/
2 +
(x
[i
]-x
[j
])*
sqrt(3.
0)/
2;
if ((p*(y[j]-y[i]) + q*(x[i]-x[j]) + (x[j]*y[i] - x[i]*y[j])) *
(x[k]*(y[j]-y[i]) + y[k]*(x[i]-x[j]) + (x[j]*y[i] - x[i]*y[j])) > 0)
{
p =
(x
[i
]+x
[j
])/
2 -
(y
[j
]-y
[i
])*
sqrt(3.
0)/
2;
q =
(y
[i
]+y
[j
])/
2 -
(x
[i
]-x
[j
])*
sqrt(3.
0)/
2;
}
double a1 = q-y[k];
double b1 = x[k]-p;
double c1 = y[k]*p-x[k]*q;
p =
(x
[i
]+x
[k
])/
2 +
(y
[k
]-y
[i
])*
sqrt(3.
0)/
2;
q =
(y
[i
]+y
[k
])/
2 +
(x
[i
]-x
[k
])*
sqrt(3.
0)/
2;
if ((p*(y[k]-y[i]) + q*(x[i]-x[k]) + (x[k]*y[i] - x[i]*y[k])) *
(x[j]*(y[k]-y[i]) + y[j]*(x[i]-x[k]) + (x[k]*y[i] - x[i]*y[k])) > 0)
{
p =
(x
[i
]+x
[k
])/
2 -
(y
[k
]-y
[i
])*
sqrt(3.
0)/
2;
q =
(y
[i
]+y
[k
])/
2 -
(x
[i
]-x
[k
])*
sqrt(3.
0)/
2;
}
double a2 = q-y[j];
double b2 = x[j]-p;
double c2 = y[j]*p-x[j]*q;
p = -(c1*b2-c2*b1)/(a1*b2-a2*b1);
q = -(a1*c2-a2*c1)/(a1*b2-a2*b1);
if (j>=n)
{
x[j] = p;
y[j] = q;
}
else
{
x[m+n] = p;
y[m+n] = q;
::p[k] = m+n;
if (::p[i] == j)
{
::p[i] = m+n;
::p[m+n] = j;
}
else
{
::p[j] = m+n;
::p[m+n] = i;
}
m++;
}
return true;
}
int main()
{
int t;
while (t--)
{
int i, j, k;
m = 0;
for (i=0; i<n; i++)
scanf("%lf%lf", x+i, y+i
);
w[0] = true;
for (i=0; i<n; i++)
r[i] = sqr(x[i]-x[0]) + sqr(y[i]-y[0]);
for (k=1; k<n; k++)
{
int c;
for (c=0; w[c]; c++);
for (i=c+1; i<n; i++)
if (!w[i] && r[i] < r[c])
c = i;
w[c] = true;
for (i=0; i<n; i++)
if (!w[i])
{
double d=sqr(x[i]-x[c]) + sqr(y[i]-y[c]);
if (r[i] > d)
{
p[i] = c;
r[i] = d;
}
}
}
for (k=0; k<1; k++)
{
for (i=1; i<n+m; i++)
for (j=i+1; j<n+m; j++)
if (p[i] == p[j])
optimize(i, p[i], j);
for (i=1; i<n+m; i++)
if (p[i] > 0)
optimize(p[p[i]], p[i], i);
}
for (i=0; i<m; i++)
printf("%lf %lf\n", x
[i+n
], y
[i+n
]);
double res = 0;
for (i=1; i<n+m; i++)
{
res += dist(i, p[i]);
}
// printf("%lf\n", res);
}
return 0;
}
-