結果
問題 | No.96 圏外です。 |
ユーザー |
|
提出日時 | 2019-04-27 01:37:03 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 1,080 ms / 5,000 ms |
コード長 | 3,553 bytes |
コンパイル時間 | 2,013 ms |
コンパイル使用メモリ | 188,724 KB |
実行使用メモリ | 22,548 KB |
最終ジャッジ日時 | 2024-11-25 21:55:31 |
合計ジャッジ時間 | 12,596 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 28 |
ソースコード
// includes#include <bits/stdc++.h>// macros#define ll long long int#define pb emplace_back#define mk make_pair#define pq priority_queue#define FOR(i, a, b) for(int i=(a);i<(b);++i)#define rep(i, n) FOR(i, 0, n)#define rrep(i, n) for(int i=((int)(n)-1);i>=0;i--)#define all(x) (x).begin(),(x).end()#define sz(x) ((int)(x).size())#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())#define FI first#define SE secondusing namespace std;// typestypedef pair<int, int> P;typedef pair<ll, int> Pl;typedef pair<ll, ll> Pll;typedef pair<double, double> Pd;// constantsconst int inf = 1e9;const ll linf = 1LL << 50;const double EPS = 1e-10;const int mod = 1e9 + 7;// solvetemplate <class T>bool chmax(T &a, const T &b){if(a < b){a = b; return 1;} return 0;}template <class T>bool chmin(T &a, const T &b){if(a > b){a = b; return 1;} return 0;}template <typename T> istream &operator>>(istream &is, vector<T> &vec){for(auto &v: vec)is >> v; return is;}typedef struct UnionFind_ {vector<int> par;vector<int> rank_;UnionFind_(int n): rank_(n, 0) {for(int i = 0; i < n; i++)par.push_back(i);}int find(int x) {if(par[x] == x)return x;else return par[x] = find(par[x]);}bool same(int x, int y) {if(find(x) == find(y))return true;else return false;}bool unite(int x, int y){int xp = find(x);int yp = find(y);if(xp == yp)return false;if(rank_[xp] > rank_[yp])par[yp] = xp;else if(rank_[xp] < rank_[yp])par[xp] = yp;else {par[yp] = xp;rank_[xp]++;}return true;}} UnionFind;map<int, int> p[20001];int base = 10000;vector<int> v[120001];int get(int i, int j){if(p[i + base].find(j) != p[i + base].end())return p[i + base][j];return -1;}double cross(const Pd &o, const Pd &a, const Pd &b){return (a.first - o.first) * (b.second - o.second) - (a.second - o.second) * (b.first - o.first);}vector<Pd> convex_hull(vector<Pd> vec){int n = vec.size(), k = 0;if(n < 3)return vec;vector<Pd> ch(2 * n);sort(vec.begin(), vec.end());// lowerfor(int i = 0; i < n; i++){while(k >= 2 && cross(ch[k-2], ch[k-1], vec[i]) <= 0.)k--;ch[k++] = vec[i];}// upperfor(int i = n - 1, t = k + 1; i > 0; --i){while(k >= t && cross(ch[k-2], ch[k-1], vec[i-1]) <= 0.)k--;ch[k++] = vec[i-1];}ch.resize(k - 1);return ch;}int main(int argc, char const* argv[]){ios_base::sync_with_stdio(false);cin.tie(0);int n;cin >> n;if(n == 0){cout << 1 << endl;return 0;}vector<int> x(n), y(n);rep(i, n)cin >> x[i] >> y[i];rep(i, n){p[x[i] + base][y[i]] = i;}UnionFind uf(n);rep(i, n){for(int j = -10; j <= 10; j++){for(int k = -10; k <= 10; k++){int in = get(x[i] + j, y[i] + k);if(in >= 0){if((x[i] - x[in]) * (x[i] - x[in]) + (y[i] - y[in]) * (y[i] - y[in]) > 100)continue;uf.unite(i, in);}}}}double res = 0;rep(i, n){v[uf.find(i)].pb(i);}for(int i = 0; i < n; i++){if(uf.find(i) != i)continue;vector<Pd> vec;for(auto c: v[i]){vec.pb(mk(x[c], y[c]));}vector<Pd> ch = convex_hull(vec);rep(j, sz(ch)){rep(k, sz(ch)){double x1 = ch[j].first, x2 = ch[k].first;double y1 = ch[j].second, y2 = ch[k].second;res = max(res, (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));}}}cout << setprecision(20);cout << 2. + sqrt(res) << endl;return 0;}