結果

問題 No.94 圏外です。(EASY)
ユーザー kotatsugamekotatsugame
提出日時 2020-02-27 19:37:50
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 17 ms / 5,000 ms
コード長 1,021 bytes
コンパイル時間 747 ms
コンパイル使用メモリ 80,868 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-03 18:53:25
合計ジャッジ時間 1,924 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 3 ms
4,376 KB
testcase_07 AC 3 ms
4,376 KB
testcase_08 AC 5 ms
4,380 KB
testcase_09 AC 9 ms
4,380 KB
testcase_10 AC 10 ms
4,380 KB
testcase_11 AC 8 ms
4,380 KB
testcase_12 AC 10 ms
4,380 KB
testcase_13 AC 9 ms
4,380 KB
testcase_14 AC 10 ms
4,376 KB
testcase_15 AC 10 ms
4,376 KB
testcase_16 AC 11 ms
4,376 KB
testcase_17 AC 10 ms
4,376 KB
testcase_18 AC 10 ms
4,376 KB
testcase_19 AC 17 ms
4,376 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:35:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
   35 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<iomanip>
#include<cmath>
using namespace std;
#include<vector>
struct UF{
	int n;
	vector<int>parent,rank;
	UF(int n_=0):n(n_),parent(n_),rank(n_,1)
	{
		for(int i=0;i<n_;i++)parent[i]=i;
	}
	int find(int a){return parent[a]!=a?parent[a]=find(parent[a]):a;}
	bool same(int a,int b){return find(a)==find(b);}
	bool unite(int a,int b)
	{
		a=find(a),b=find(b);
		if(a==b)return false;
		if(rank[a]<rank[b])
		{
			parent[a]=b;
			rank[b]+=rank[a];
		}
		else
		{
			parent[b]=a;
			rank[a]+=rank[b];
		}
		return true;
	}
	int size(int a){return rank[find(a)];}
};
int N;
int x[1000],y[1000];
main()
{
	cin>>N;
	if(N==0)
	{
		cout<<1<<endl;
		return 0;
	}
	for(int i=0;i<N;i++)cin>>x[i]>>y[i];
	UF uf(N);
	for(int i=0;i<N;i++)for(int j=0;j<N;j++)
	{
		if((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j])<=100)uf.unite(i,j);
	}
	double ans=0;
	for(int i=0;i<N;i++)for(int j=0;j<N;j++)
	{
		if(uf.same(i,j))ans=max(ans,hypot(x[i]-x[j],y[i]-y[j]));
	}
	cout<<fixed<<setprecision(16)<<ans+2<<endl;
}
0