/* -*- coding: utf-8 -*- * * 168.cc: No.168 ものさし - yukicoder */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; /* constant */ const int MAX_N = 1000; const int MAX_M = MAX_N * (MAX_N - 1) / 2; /* typedef */ typedef long long ll; struct Edge { ll d; int i, j; Edge() {} Edge(ll _d, int _i, int _j): d(_d), i(_i), j(_j) {} bool operator<(const Edge &e) const { return d < e.d; } void print() { printf("%lld[%d,%d]\n", d, i, j); } }; struct UFT { int links[MAX_N], ranks[MAX_N], sizes[MAX_N]; void clear(int n) { for (int i = 0; i < n; i++) links[i] = i, ranks[i] = sizes[i] = 1; } UFT() {} UFT(int n) { clear(n); } int root(int i) { int i0 = i; while (links[i0] != i0) i0 = links[i0]; return (links[i] = i0); } int rank(int i) { return ranks[root(i)]; } int size(int i) { return sizes[root(i)]; } bool same(int i, int j) { return root(i) == root(j); } int merge(int i0, int i1) { int r0 = root(i0), r1 = root(i1), mr; if (r0 == r1) return r0; if (ranks[r0] == ranks[r1]) { links[r1] = r0; sizes[r0] += sizes[r1]; ranks[r0]++; mr = r0; } else if (ranks[r0] > ranks[r1]) { links[r1] = r0; sizes[r0] += sizes[r1]; mr = r0; } else { links[r0] = r1; sizes[r1] += sizes[r0]; mr = r1; } return mr; } }; /* global variables */ ll xs[MAX_N], ys[MAX_N]; Edge es[MAX_M]; UFT uft; /* subroutines */ /* main */ int main() { int n; cin >> n; for (int i = 0; i < n; i++) cin >> xs[i] >> ys[i]; int m = 0; for (int i = 0; i < n; i++) for (int j = i + 1; j < n; j++) { ll dx = xs[j] - xs[i], dy = ys[j] - ys[i]; es[m++] = Edge(dx * dx + dy * dy, i, j); } sort(es, es + m); //for (int i = 0; i < m; i++) es[i].print(); uft.clear(n); ll maxd2 = 0; for (int i = 0; i < m; i++) { Edge &ei = es[i]; if (! uft.same(ei.i, ei.j)) { uft.merge(ei.i, ei.j); maxd2 = ei.d; if (uft.same(0, n - 1)) break; } } //printf("maxd2=%lld\n", maxd2); printf("%lld\n", (ll)ceill(sqrtl((long double)maxd2) / 10) * 10); return 0; }