結果
問題 | No.94 圏外です。(EASY) |
ユーザー |
![]() |
提出日時 | 2018-11-17 00:22:09 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 10 ms / 5,000 ms |
コード長 | 1,209 bytes |
コンパイル時間 | 2,237 ms |
コンパイル使用メモリ | 200,168 KB |
最終ジャッジ日時 | 2025-01-06 16:45:30 |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 22 |
ソースコード
#include<bits/stdc++.h> using namespace std; using Int = long long; template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;} template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;} struct UnionFind{ Int n; vector<Int> r,p; UnionFind(){} UnionFind(Int sz):n(sz),r(sz,1),p(sz,0){iota(p.begin(),p.end(),0);} Int find(Int x){ return (x==p[x]?x:p[x]=find(p[x])); } bool same(Int x,Int y){ return find(x)==find(y); } void unite(Int x,Int y){ x=find(x);y=find(y); if(x==y) return; if(r[x]<r[y]) swap(x,y); r[x]+=r[y]; p[y]=x; } }; struct Precision{ Precision(){ cout<<fixed<<setprecision(12); } }precision_beet; //INSERT ABOVE HERE signed main(){ Int n; cin>>n; vector<Int> x(n),y(n); for(Int i=0;i<n;i++) cin>>x[i]>>y[i]; UnionFind uf(n); auto l2norm=[&](Int i,Int j){ return (x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]);}; for(Int i=0;i<n;i++) for(Int j=0;j<n;j++) if(l2norm(i,j)<=100) uf.unite(i,j); double ans=1; for(Int i=0;i<n;i++) for(Int j=0;j<n;j++) if(uf.same(i,j)) chmax(ans,sqrt(double(l2norm(i,j)))+2.0); cout<<ans<<endl; return 0; }