結果
| 問題 | No.96 圏外です。 |
| コンテスト | |
| ユーザー |
yaoshimax
|
| 提出日時 | 2015-03-08 18:03:44 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 4,044 bytes |
| 記録 | |
| コンパイル時間 | 1,263 ms |
| コンパイル使用メモリ | 106,644 KB |
| 実行使用メモリ | 814,052 KB |
| 最終ジャッジ日時 | 2024-06-24 16:07:58 |
| 合計ジャッジ時間 | 30,059 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 11 WA * 3 MLE * 3 -- * 11 |
ソースコード
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
using namespace std;
class UnionFindTree
{
private:
int N;
int *rootnum;
int *rank;
int *unionnum;
public:
UnionFindTree(int n){
/*0からn-1までの要素をunionとしてもつ*/
N = n;
rootnum = new int[N];
rank = new int[N];
unionnum = new int[N];
for( int i = 0 ; i < N ; i++ ){
rootnum[i] = i;
rank[i] = 0;
unionnum[i] = 1;
}
}
int Find( int j ){
if( rootnum[j] == j ){
return j;
}
else{
return rootnum[j] = Find(rootnum[j]);
}
}
void Union( int i , int j ){
int x = Find(i);
int y = Find(j);
if( x == y ) return;
N--;
if( rank[x] < rank[y] ){
rootnum[y] = x;
unionnum[x] += unionnum[y];
}else{
rootnum[x] = y;
unionnum[y] += unionnum[x];
if( rank[x]==rank[y] ) rank[x]++;
}
}
int Num( int j ){
/*与えられた要素の入っている集合の要素数を答える*/
int x = Find(j);
return unionnum[x];
}
int UnionNum(){
/*集合の数を答える*/
return N;
}
~UnionFindTree(){
delete rootnum;
delete rank;
delete unionnum;
}
};
long long product( pair<int,int> p1, pair<int,int> p2, pair<int,int> p3 ){
pair<int,int> v1 = make_pair( p2.first-p1.first, p2.second-p1.second);
pair<int,int> v2 = make_pair( p3.first-p1.first, p3.second-p1.second);
return v1.first*(long long)v2.second-v1.second*(long long)v2.first;
}
vector< pair<int,int> > convex_hull( vector<pair<int,int> > &V){
sort(V.begin(),V.end());
if( V.size() <=2 ) return V;
int size = V.size();
vector<pair<int,int> > ret(size*2);
int retlen=0;
for( int i = 0 ; i <size; i++ ){
while( retlen >= 2 && product( ret[retlen-2],ret[retlen-1],V[i] ) >= 0 ) retlen--;
ret[retlen++]=V[i];
}
for( int i = size-1 ; i > 0 ; i-- ){
while( retlen >= 2 && product( ret[retlen-2],ret[retlen-1],V[i] ) >= 0 ) retlen--;
ret[retlen++]=V[i];
}
ret.resize(retlen);
return ret;
}
pair<int,int> points[120001];
vector< pair<int,int > > V[120001];
int main(){
int N;
cin >> N;
map< pair<int,int>, int> m;
UnionFindTree uft(N);
for( int i = 0 ; i < N ; i++ ){
V[i].clear();
cin >> points[i].first >> points[i].second;
m[points[i]]=i+1;
}
if( N == 0 ){
printf("%.10f\n",1.0);
return 0;
}
for( int i = 0 ; i < N ; i++ ){
int x = points[i].first;
int y = points[i].second;
for( int x2 = x ; x2 <= x+10; x2++ ){
for( int y2 = y-10; y2 <= y+10; y2++ ){
if( x==x2 && y==y2) continue;
if( (x2-x)*(x2-x)+(y2-y)*(y2-y) > 100 ) continue;
if( m[make_pair(x2,y2)]>0){
int ind = m[make_pair(x2,y2)];
uft.Union(i,ind-1);
}
}
}
}
for( int i = 0 ; i < N ; i++ ){
V[uft.Find(i)].push_back(points[i]);
}
long long maxDist = 0;
for( int i = 0 ; i <N; i++ ){
vector<pair<int,int> > convPoints = convex_hull(V[i]);
for( int j = 0 ; j < (int) convPoints.size(); j ++ ){
for( int k = j+1 ; k < (int) convPoints.size(); k++ ){
long long dx = convPoints[j].first-convPoints[k].first;
long long dy = convPoints[j].second-convPoints[k].second;
maxDist = max(maxDist,dx*dx+dy*dy);
}
}
}
printf("%.10f\n",2.0+sqrt((double)maxDist));
return 0;
}
yaoshimax