#include using namespace std; #define int long long struct edge{ int u,v,cost; }; bool comp(const edge& e1,const edge& e2){ return e1.cost < e2.cost; } vector es; int V,E; //頂点数、辺数 struct UF{ vector par; //親 vector size; //集合の大きさ void init(int n){ par.resize(n); size.resize(n); for(int i = 0; i < n; i++){ par[i] = i; size[i] = 1; } } //木の根を求める int root(int x){ if(par[x] == x){ return x; } else { return par[x] = root(par[x]); } } //xとyの属する集合を併合 void unite(int x,int y){ x = root(x); y = root(y); if(x == y) return; if(size[x] < size[y]) swap(x,y); par[y] = x; size[x] += size[y]; } }uf; int kruskal(int ok){ //sort(es.begin(),es.end(),comp); uf.init(V); int total = 0; for(int i = 0; i < es.size(); i++){ edge e = es[i]; if(e.cost > ok) break; if(uf.root(e.u) != uf.root(e.v)){ total += e.cost; uf.unite(e.u,e.v); } } return uf.root(0) == uf.root(V-1); } signed main(){ cin.tie(0); ios::sync_with_stdio(false); cin >> V; vector x(V),y(V); for(int i = 0; i < V; i++){ cin >> x[i] >> y[i]; } for(int i = 0; i < V; i++){ for(int j = i+1; j < V; j++){ int cost = abs(x[i] - x[j])*abs(x[i] - x[j]) + abs(y[i] - y[j])*abs(y[i] - y[j]); es.push_back({i,j,cost}); cout << cost << endl; } } sort(es.begin(),es.end(),comp); function< int(int) > check = [&](int mid){ if(kruskal(mid*mid)) return 1LL; return 0LL; }; int ok = -1, ng = 1e9+10; while(ng - ok > 1){ int mid = (ok + ng) / 2; if(!check(mid)) ok = mid + 1; else ng = mid; } while(ok%10 != 0) ok++; cout << ok << endl; return 0; }