結果

問題 No.94 圏外です。(EASY)
ユーザー yuustiyuusti
提出日時 2014-12-08 23:42:50
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 3,955 bytes
コンパイル時間 1,553 ms
コンパイル使用メモリ 115,256 KB
実行使用メモリ 4,828 KB
最終ジャッジ日時 2023-09-02 11:51:28
合計ジャッジ時間 2,692 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 2 ms
4,652 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 -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric>
#include <cctype>
#include <tuple>
#include <climits>
#include <bitset>
#include <cassert>
#include <random>
#include <complex>

#ifdef _MSC_VER
#include <agents.h>
#endif

#define FOR(i, a, b) for(int i = (a); i < (int)(b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define REV(v) v.rbegin(), v.rend()
#define MEMSET(v, s) memset(v, s, sizeof(v))
#define UNIQUE(v) (v).erase(unique(ALL(v)), (v).end())
#define MP make_pair
#define MT make_tuple

using namespace std;

typedef long long ll;
//typedef pair<int, int> P;

const double EPS = 1e-8;
const double INF = 1e12;

typedef complex<double> P;
typedef P point;

namespace std {
	bool operator < (const P& a, const P& b) {
		return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
	}
}
double cross(const P& a, const P& b) {
	return imag(conj(a)*b);
}
double dot(const P& a, const P& b) {
	return real(conj(a)*b);
}

struct L : public vector<P> {
	L(const P &a, const P &b) {
		push_back(a); push_back(b);
	}
};

typedef vector<P> G;

struct C {
	P p; double r;
	C(const P &p, double r) : p(p), r(r) { }
};
int ccw(P a, P b, P c) {
	b -= a; c -= a;
	if (cross(b, c) > 0)   return +1;       // counter clockwise
	if (cross(b, c) < 0)   return -1;       // clockwise
	if (dot(b, c) < 0)     return +2;       // c--a--b on line
	if (norm(b) < norm(c)) return -2;       // a--b--c on line
	return 0;
}

vector<point> convex_hull(vector<point> &ps) {
	int n = ps.size(), k = 0;
	sort(ps.begin(), ps.end());
	vector<point> ch(2 * n);
	for (int i = 0; i < n; ch[k++] = ps[i++]) // lower-hull
	while (k >= 2 && ccw(ch[k - 2], ch[k - 1], ps[i]) <= 0) --k;
	for (int i = n - 2, t = k + 1; i >= 0; ch[k++] = ps[i--]) // upper-hull
	while (k >= t && ccw(ch[k - 2], ch[k - 1], ps[i]) <= 0) --k;
	ch.resize(k - 1);
	return ch;
}

typedef double number;
typedef vector<P> polygon;

#define curr(P, i) P[i]
#define next(P, i) P[(i+1)%P.size()]
#define diff(P, i) (next(P, i) - curr(P, i))
number convex_diameter(const polygon &pt) {
	double d = 0;
	for (auto p1 : pt) for (auto p2 : pt) d = max(d, norm(p1 - p2));

	return d;
}

const int N = 120010;
struct UnionFind{
	int par[N];

	UnionFind(int n){
		iota(par, par + n, 0);
	}
	int find(int x){
		if (par[x] == x) return x;
		return par[x] = find(par[x]);
	}
	void unite(int x, int y){
		par[find(x)] = find(y);
	}
};

const int X = 10020;
map<int, int> yy[20050];

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);

	int n;
	cin >> n;
	vector<P> vp;
	rep(i, n){
		int x, y;
		cin >> x >> y;
		vp.emplace_back(P(x, y));
		yy[X + x][y] = i;
	}

	UnionFind uf(n);
	rep(i, n){
		int x = X + vp[i].real();
		int y = vp[i].imag();
		for (int dx = -10; dx <= 10; ++dx){
			int dy = sqrt(100 - dx*dx);
			cout << -dy << ' ' << dy << endl;
			if (yy[x + dx].empty()) continue;
			auto it1 = yy[x + dx].lower_bound(y - dy);
			auto it2 = yy[x + dx].upper_bound(y + dy);
			while (it1 != it2){
				uf.unite(i, it1->second);
				++it1;
			}
		}
	}

	vector<int> num(n);
	rep(i, n) num[i] = uf.find(i);
	sort(ALL(num));
	UNIQUE(num);
	auto get = [&](int x){return lower_bound(ALL(num), x) - num.begin(); };

	vector<vector<P>> gr(num.size());
	rep(i, n) gr[get(uf.find(i))].push_back(vp[i]);

	double ans = 0;
	for (auto &poly : gr){
        if (poly.size() <= 2){
			if(poly.size() != 1) ans = max(ans, abs(poly[0] - poly[1]));
		}
		else{
			ans = max(ans, sqrt(convex_diameter(convex_hull(poly))));
		}
	}
	cout.setf(ios::fixed);
	cout.precision(12);

	cout << ans + 1 + (n!=0) << endl;

	return 0;
}
0