結果

問題 No.94 圏外です。(EASY)
ユーザー IL_msta
提出日時 2015-07-12 10:11:03
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 9 ms / 5,000 ms
コード長 1,690 bytes
コンパイル時間 904 ms
コンパイル使用メモリ 94,792 KB
実行使用メモリ 7,600 KB
最終ジャッジ日時 2024-06-26 07:37:45
合計ジャッジ時間 1,733 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
 
#include <iostream>
#include <iomanip>
 
#include <algorithm>
#include <cmath>
 
#include <string>
//#include <array>
#include <list>
#include <queue>
#include <vector>
#include <complex>
#include <set>
#include <map>
 
/////////
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define P(p) cout<<(p)<<endl;
 
#define PII pair<int,int>
/////////
typedef long long LL;
typedef long double LD;
/////////
using namespace::std;
/////////
int X[1000],Y[1000];
int Len[1000][1000];

int main(void){
    std::cin.tie(0); 
    std::ios::sync_with_stdio(false);
    std::cout << std::fixed;//
    cout << setprecision(10);//

    int N;
	cin>>N;
	
	rep(i,N){
		cin>>X[i]>>Y[i];
	}

	if(N==0){P(1.0);return 0;}
	else if( N==1){P(2.0);return 0;}

	rep(i,N)for(int j= i+1;j<N;++j){
		Len[i][j] = (X[i]-X[j])*(X[i]-X[j])+(Y[i]-Y[j])*(Y[i]-Y[j]);
	}

	bool use[1000];
	rep(i,N)use[i]=false;
	int cMax=0,tcMax;
	rep(i,N){
		if(use[i]==true)continue;
		queue<int> que;
		vector<int> tree;
		que.push(i);
		use[i] = true;
		tree.push_back(i);
		int now;
		while( !que.empty() ){
			now = que.front();
			que.pop();
			rep(k,N){
				if(now==k || use[k]==true )continue;
				if( Len[min(now,k)][max(now,k)] <= 100 ){
						que.push(k);
						use[k] = true;
						tree.push_back(k);
				}	
			}
		}
		tcMax = 0;
		if(tree.size() > 1){
			int temp;
			sort( tree.begin(), tree.end() );
			for(int tA=0;tA<tree.size();++tA){
				for(int tB=tA+1;tB<tree.size();++tB){
					temp = Len[ tree[tA] ][ tree[tB] ];
					if(tcMax < temp){
						tcMax = temp;
					}
				}
			}
		}
		if(cMax < tcMax){
			cMax = tcMax;
		}
	}
	P(2.0+sqrt(1.0*cMax));
    return 0;
}
0