#include <assert.h>
#include <vector>
#include <string>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <cmath>
#include <set>
#define maxn 3000
#define maxm 7000
#define DIST(u, v) ((x[u] - x[v]) * (x[u] - x[v]) + (y[u] - y[v]) * (y[u] - y[v]))
#define POLAR(u, v) atan2(x[v] - x[u], y[v] - y[u])
#define UPDATE(a, b, c, d) \
adj[d].clear(); \
adj[a].erase(b); adj[a].erase(c); adj[b].erase(a); adj[c].erase(a); \
adj[a].insert(d); adj[b].insert(d); adj[c].insert(d); \
adj[d].insert(a); adj[d].insert(b); adj[d].insert(c); \
//cout << a << " " << b << " " << c << " " << d << endl;
#define cos60 0.5
#define sin60 0.8660254037844386
#define pi 3.1415926535897932384
#define eps 1e-5
#define eps2 1e-6
using namespace std;
double x[maxm], y[maxm], best[maxn];
int p[maxn], parent[maxn], n, m;
set<int> adj[maxm];
struct adjVertex {
int v;
double phi;
adjVertex(int u0, int v) {
this->v = v;
this->phi = POLAR(u0, v);
}
};
bool operator<(const adjVertex& a, const adjVertex& b) {
return a.phi > b.phi;
}
bool steiner(int a, int b, int c, int d) {
if (b == c || a == b || a == c || d >= 2 * n) return false;
double la = DIST(b, c);
double lb = DIST(a, c);
double lc = DIST(a, b);
if (la < eps2 || lb < eps2 || lc < eps2) return false;
double cosa =
(lb + lc - la
) /
2.
0 /
sqrt(lb
) /
sqrt(lc
);
double cosb =
(la + lc - lb
) /
2.
0 /
sqrt(la
) /
sqrt(lc
);
double cosc =
(la + lb - lc
) /
2.
0 /
sqrt(la
) /
sqrt(lb
);
if (cosa < eps - 0.5 || cosb < eps - 0.5 || cosc < eps - 0.5) return false;
if (cosb < cosc && cosb < cosa) return steiner(b, a, c, d);
if (cosc < cosb && cosc < cosa) return steiner(c, a, b, d);
double dx = x[b] - x[c];
double dy = y[b] - y[c];
x[d + 1] = dx * cos60 + dy * sin60 + x[c];
y[d + 1] = -dx * sin60 + dy * cos60 + y[c];
x[d + 2] = dx * cos60 - dy * sin60 + x[c];
y[d + 2] = dx * sin60 + dy * cos60 + y[c];
int D = DIST(d + 1, a) > DIST(d + 2, a) ? d + 1 : d + 2;
-
double ld = DIST(a, D);
double cose =
(lb + ld - la
) /
2.
0 /
sqrt(lb
) /
sqrt(ld
);
double sine =
sqrt(1 - cose * cose
);
double phie =
acos(cose
);
double phif = pi / 3.0 - phie;
double lle =
sqrt(lb
) * sine / sin60;
-
dx =
(x
[a
] - x
[c
]) /
sqrt(lb
) * lle;
dy =
(y
[a
] - y
[c
]) /
sqrt(lb
) * lle;
x[d + 1] = dx * cosf + dy * sinf + x[c];
y[d + 1] = -dx * sinf + dy * cosf + y[c];
x[d + 2] = dx * cosf - dy * sinf + x[c];
y[d + 2] = dx * sinf + dy * cosf + y[c];
D = DIST(d + 1, b) < DIST(d + 2, b) ? d + 1 : d + 2;
-
x[d] = x[D];
y[d] = y[D];
return (x[d] > -1e6 && x[d] < 1e6 && y[d] > -1e6 && y[d] < 1e6);
}
void greedy() {
int i, j, current, first, k;
m = 0;
for (i = 0; i < n; i++) if (adj[i].size() > 1) {
vector<adjVertex> adjv;
for (set<int>::iterator it = adj[i].begin(); it != adj[i].end(); it++) adjv.push_back(adjVertex(i, *it));
sort(adjv.begin(), adjv.end());
current = adjv[0].v;
first = current;
bool failed = false;
for (j = 1; j < adjv.size(); j++)
if (steiner(i, current, adjv[j].v, n + m)) {
UPDATE(i, current, adjv[j].v, n + m)
current = n + m;
if (!failed) first = current;
m += 1;
} else {
current = adjv[j].v;
failed = true;
}
if (steiner(i, first, current, n + m)) {
UPDATE(i, first, current, n + m)
m += 1;
}
}
}
int main() {
/*freopen("zelc.in", "rt", stdin);
freopen("zelc.out", "wt", stdout);*/
int testCount, i, j, k, lim, v0;
-
while (testCount--) {
v0 = 1;
for (i =
0; i < n; i++
) scanf("%lf %lf", &x
[i
], &y
[i
]);
for (i = 0; i < n; i++) {
best[i] = DIST(v0, i);
p[i] = i < v0 ? i : i + 1;
parent[i] = v0;
}
for (lim = n - 1, i = 1; i < n; i++) {
for (k = 0, j = 0; j < lim; j++) if (best[p[k]] > best[p[j]]) k = j;
m = p[k];
p[k] = p[--lim];
for (j = 0; j < lim; j++) {
double dist = DIST(m, p[j]);
if (best[p[j]] > dist) {
best[p[j]] = dist;
parent[p[j]] = m;
}
}
}
for (i = 0; i < n; i++) adj[i].clear();
for (i = 0; i < n; i++) if (i != v0) {
adj[i].insert(parent[i]);
adj[parent[i]].insert(i);
}
greedy();
for (i = n; i < n + m; i++
) printf("%lf %lf\n", x
[i
], y
[i
]);
for (j = 0, i = 0; i < n + m; i++) {
for (set<int>::iterator it = adj[i].begin(); it != adj[i].end(); it++) {
int vertex = *it;
if (vertex > i
) { printf("%d %d\n", i, vertex
); j++;
};
}
}
}
}