#include #include #include class DisjointSet { public: std::vector rank, p; DisjointSet() {} DisjointSet(int size) { rank.resize(size, 0); p.resize(size, 0); for(int i = 0; i < size; i++) { p[i] = i; rank[i] = 0; } } bool same(int x, int y) { return findSet(x) == findSet(y); } void unite(int x, int y) { link(findSet(x), findSet(y)); } void link(int x, int y) { if(rank[x] > rank[y]) { p[y] = x; } else { p[x] = y; if(rank[x] == rank[y]) { rank[y]++; } } } int findSet(int x) { if(x != p[x]) { p[x] = findSet(p[x]); } return p[x]; } }; int n; long long x[1001]; long long y[1001]; long long d[1001][1001]; bool ok(long long dist) { DisjointSet ds(n); for(int i = 0; i < n; i++) { for(int j = 0; j < n; j++) { if(d[i][j] <= dist * dist) { ds.unite(i, j); } } } return ds.same(0, n-1); } int main() { std::cin.tie(0); std::ios::sync_with_stdio(false); std::cin >> n; for(int i = 0; i < n; i++) { std::cin >> x[i] >> y[i]; } for(int i = 0; i < n; i++) { for(int j = 0; j < n; j++) { long long dx = x[i] - x[j]; long long dy = y[i] - y[j]; d[i][j] = dx * dx + dy * dy; } } long long left = 0; long long right = 1000000001; while(left < right) { long long mid = (left + right) / 2; if(ok(mid)) { right = mid; } else { left = mid + 1; } } long long ans; if(left % 10 != 0) { ans = left + (10 - (left % 10)); } else { ans = left; } std::cout << ans << std::endl; }