#include using namespace std; #define rep(i,n) for(int i=0;i=0;--i) #define debug(output) if(debugFlag)cout<<#output<<"= "< P; const bool debugFlag=true; const lint linf=1.1e18;const int inf=1.01e9; constexpr int MOD=1000000007; templatebool chmax(T &a, const T &b) { if(a < b){ a = b; return 1; } return 0; } templatebool chmin(T &a, const T &b) { if(a > b){ a = b; return 1; } return 0; } double eps = 0.00000001; double dist(array a,array b){ if(a[2]==b[2]){ return sqrt((a[0]-b[0])*(a[0]-b[0])+(a[1]-b[1])*(a[1]-b[1])); } return abs(sqrt(a[0]*a[0]+a[1]*a[1])-sqrt(b[0]*b[0]+b[1]*b[1])); } signed main(){ int n;cin>>n; vector> a(n); rep(i,n)rep(j,3)cin>>a[i][j]; vector>> edge(n+1); rep(i,n){ rep(j,i){ edge[i].push_back({j,(lint)ceil(dist(a[i],a[j])*dist(a[i],a[j])+eps)}); edge[j].push_back({i,(lint)ceil(dist(a[i],a[j])*dist(a[i],a[j]))}); } } vector dp(n+1,linf); priority_queue,vector>,greater>> que; dp[0]=0; que.push({0,0}); vector seen(n,false); while(!que.empty()){ auto [d,v]=que.top();que.pop(); if(seen[v])continue; seen[v]=true; for(auto& e:edge[v]){ chmin(dp[e[0]],max(d,e[1])); que.push({max(d,e[1]),e[0]}); } } // rep(i,n)debug(dp[i]); cout<