結果

問題 No.96 圏外です。
ユーザー 古寺いろは古寺いろは
提出日時 2015-04-10 21:52:20
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 2,473 bytes
コンパイル時間 1,412 ms
コンパイル使用メモリ 156,888 KB
実行使用メモリ 106,148 KB
最終ジャッジ日時 2023-09-17 19:12:41
合計ジャッジ時間 17,458 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
100,504 KB
testcase_01 AC 38 ms
100,784 KB
testcase_02 AC 39 ms
100,764 KB
testcase_03 AC 38 ms
100,408 KB
testcase_04 AC 52 ms
100,640 KB
testcase_05 AC 74 ms
100,768 KB
testcase_06 AC 127 ms
100,948 KB
testcase_07 AC 607 ms
101,056 KB
testcase_08 AC 422 ms
101,180 KB
testcase_09 AC 774 ms
101,284 KB
testcase_10 AC 3,853 ms
101,844 KB
testcase_11 AC 2,215 ms
102,060 KB
testcase_12 AC 551 ms
102,660 KB
testcase_13 TLE -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;

typedef complex<double> P;
namespace std {
	bool operator < (const P& a, const P& b) {
		return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
	}
}

#define EPS 1e-8

struct C {
	P p; double r;
	C(const P &p, double r) : p(p), r(r) { }
};

bool xy_less(const P& a, const P& b) {
	if (abs(a.imag() - b.imag()) < EPS) return (a.real() < b.real());
	return (a.imag() < b.imag());
}
double ccw(P a, P b, P c) {
	return (conj(b - a)*(c - a)).imag();
}
template<class IN>
void walk_rightside(IN begin, IN end, vector<P>& v) {
	IN cur = begin;
	v.push_back(*cur++);
	vector<P>::size_type s = v.size();
	v.push_back(*cur++);
	while (cur != end) {
		if (v.size() == s || ccw(v[v.size() - 2], v.back(), *cur) > EPS)
			v.push_back(*cur++);
		else
			v.pop_back();
	}
	v.pop_back();
}
vector<P> convex_hull(vector<P> v) {
	if (v.size() <= 1)
		return v; // EXCEPTIONAL
	sort(v.begin(), v.end(), xy_less);
	vector<P> cv;
	walk_rightside(v.begin(), v.end(), cv);
	walk_rightside(v.rbegin(), v.rend(), cv);
	return cv;
}

vector<int> box[2004][2004];
vector<P> p2[130002];

int unidp[130002];

int findunidp(int a){
	if (unidp[a] < 0) return a;
	else return unidp[a] = findunidp(unidp[a]);
}

bool connect(int a, int b){
	a = findunidp(a);
	b = findunidp(b);
	if (a == b) return false;
	unidp[a] += unidp[b];
	unidp[b] = a;
	return true;
}

int main(){
	int N;
	cin >> N;
	vector<P> ps;
	for (int i = 0; i < N; i++)
	{
		int X, Y;
		cin >> X >> Y;
		ps.push_back(P(X + 10000, Y + 10000));
		unidp[i] = -1;
	}
	if (N == 0){
		cout << 1 << endl;
		return 0;
	}

	for (int i = 0; i < N; i++)
	{
		int Xb = (int)(ps[i].real()) / 1000 + 1;
		int Yb = (int)(ps[i].imag()) / 1000 + 1;
		for (int dy = -1; dy <= 1; dy++)
		{
			for (int dx = -1; dx <= 1; dx++)
			{
				int nXb = Xb + dx;
				int nYb = Yb + dy;
				for (int j : box[nXb][nYb])
				{
					if (abs(ps[i] - ps[j]) <= 10){
						connect(i, j);
					}
				}
			}
		}
		box[Xb][Yb].push_back(i);
	}

	for (int i = 0; i < N; i++)
	{
		p2[findunidp(i)].push_back(ps[i]);
	}

	double ans = 0;
	for (int i = 0; i < N; i++)
	{
		if (p2[i].size() < 2) continue;
		int M = p2[i].size();
		int p = 0;
		int q = 0;
		for (int j = 0; j < M; j++)
		{
			while (true){
				q = p + 1; q %= M;
				double d1 = abs(p2[i][j] - p2[i][p]);
				double d2 = abs(p2[i][j] - p2[i][q]);
				ans = max(ans, d2);
				if (d1 >= d2) break;
				p = q;
			}
		}
	}
	ans += 2;
	printf("%.14f\n", ans);
}
0