結果

問題 No.96 圏外です。
ユーザー fumiphysfumiphys
提出日時 2019-04-27 01:34:55
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 3,539 bytes
コンパイル時間 2,494 ms
コンパイル使用メモリ 186,652 KB
実行使用メモリ 18,276 KB
最終ジャッジ日時 2023-08-17 04:15:37
合計ジャッジ時間 11,533 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
7,380 KB
testcase_01 AC 5 ms
7,376 KB
testcase_02 AC 5 ms
7,220 KB
testcase_03 AC 5 ms
7,104 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 5 ms
7,288 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

// 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 second
using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
const int mod = 1e9 + 7;

// solve
template <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());

  // lower
  for(int i = 0; i < n; i++){
    while(k >= 2 && cross(ch[k-2], ch[k-1], vec[i]) <= 0.)k--;
    ch[k++] = vec[i];
  }

  // upper
  for(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(j, 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;
}
0