結果
問題 |
No.96 圏外です。
|
ユーザー |
![]() |
提出日時 | 2024-07-13 01:14:31 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 1,606 ms / 5,000 ms |
コード長 | 3,021 bytes |
コンパイル時間 | 2,059 ms |
コンパイル使用メモリ | 153,056 KB |
実行使用メモリ | 24,936 KB |
最終ジャッジ日時 | 2025-04-28 06:32:51 |
合計ジャッジ時間 | 15,161 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 28 |
ソースコード
#include<iostream> #include<vector> #include<algorithm> using namespace std; using ll = long long; #include<iomanip> #include<math.h> ll cross(ll a,ll b,ll c,ll d){ return a * d - b * c; } int ccw(pair<ll,ll> a,pair<ll,ll> b,pair<ll,ll> c) { ll dx = b.first - a.first; ll dy = b.second - a.second; ll ddx = c.first - b.first; ll ddy = c.second - b.second; ll now = cross(dx,dy,ddx,ddy); if(now<0) return -1; if(now>0) return 1; return 0; } long double calc(vector<pair<ll,ll>> use) { int n = use.size(); sort(use.begin(),use.end()); if(n==1) return 2; vector<pair<ll,ll>> upper,lower; for(int i = 0;i<n;i++){ while(upper.size()>=2){ int m = upper.size(); if(ccw(upper[m-2],upper[m-1],use[i])!=-1) upper.pop_back(); else break; } upper.push_back(use[i]); } for(int i = 0;i<n;i++){ while(lower.size()>=2){ int m = lower.size(); if(ccw(lower[m-2],lower[m-1],use[i])!=1) lower.pop_back(); else break; } lower.push_back(use[i]); } ll ans = 0; reverse(lower.begin(),lower.end()); for(int i = 1;i+1<lower.size();i++) upper.push_back(lower[i]); int ni = 0; int m = upper.size(); auto d = [&](int i,int j) -> ll { ll dx = upper[i].first - upper[j].first; ll dy = upper[i].second - upper[j].second; return (dx*dx+dy*dy); }; bool fn = false; for(int i = 0;i<m;i++){ while(true){ ans = max(ans,d(i,ni)); int nj = ni + 1; if(nj==m){ nj = 0; fn = true; } if(nj==i) break; if(d(i,nj)>d(i,ni)) ni = nj; else break; } ans = max(d(i,ni),ans); if(fn) break; } return sqrt(ans) + 2; } #include<atcoder/dsu> #include<map> int main(){ cin.tie(nullptr); ios::sync_with_stdio(false); int n; cin>>n; vector<ll> x(n),y(n); for(int i = 0;i<n;i++) cin>>x[i]>>y[i]; int B = 10000; for(int i = 0;i<n;i++) x[i] += B; vector<map<int,int>> memo(1<<17); atcoder::dsu uf(n); long double ans = 1; for(int i = 0;i<n;i++) memo[x[i]][y[i]] = i; for(int i = 0;i<n;i++){ for(int ni = 0;ni<=10;ni++){ for(int nj = 0;nj<=10;nj++){ ll now = ni * ni + nj * nj; if(now>100) break; for(int nni = -1;nni<=1;nni+=2) for(int nnj = -1;nnj<=1;nnj+=2){ int xx = x[i] + ni * nni; int yy = y[i] + nj * nnj; if(xx<0) continue; if(memo[xx].find(yy)!=memo[xx].end()) uf.merge(i,memo[xx][yy]); } } } } for(auto&now:uf.groups()){ vector<pair<ll,ll>> use; for(int i:now) use.push_back(make_pair(x[i],y[i])); ans = max(ans,calc(use)); } cout<<setprecision(30)<<fixed<<ans<<endl; }