結果

問題 No.94 圏外です。(EASY)
ユーザー 37zigen37zigen
提出日時 2016-03-25 01:57:31
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,208 bytes
コンパイル時間 2,256 ms
コンパイル使用メモリ 77,244 KB
実行使用メモリ 62,180 KB
最終ジャッジ日時 2024-04-09 23:44:23
合計ジャッジ時間 9,035 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 127 ms
54,120 KB
testcase_01 WA -
testcase_02 AC 123 ms
53,728 KB
testcase_03 AC 105 ms
52,828 KB
testcase_04 AC 193 ms
55,400 KB
testcase_05 AC 234 ms
58,396 KB
testcase_06 AC 244 ms
58,936 KB
testcase_07 AC 269 ms
59,756 KB
testcase_08 AC 310 ms
60,856 KB
testcase_09 AC 361 ms
61,912 KB
testcase_10 AC 360 ms
61,948 KB
testcase_11 AC 366 ms
62,032 KB
testcase_12 AC 377 ms
61,136 KB
testcase_13 AC 374 ms
61,032 KB
testcase_14 AC 348 ms
60,340 KB
testcase_15 AC 364 ms
61,596 KB
testcase_16 AC 369 ms
60,064 KB
testcase_17 AC 378 ms
59,948 KB
testcase_18 AC 377 ms
60,232 KB
testcase_19 AC 369 ms
62,180 KB
testcase_20 AC 144 ms
54,328 KB
testcase_21 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

package yukicoder094;

import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		double[] x=new double[n];
		double[] y=new double[n];
		UnionFind uni=new UnionFind(n);
		for(int i=0;i<n;i++){
			x[i]=sc.nextDouble();
			y[i]=sc.nextDouble();
		}

		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				if(i==j)continue;
				if((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j])<=100){
					uni.setUnion(i, j);	
				}
			}
		}
		double max=0;
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				if(i==j)continue;
				if(uni.root(i)==uni.root(j)){
					max=Math.max(max,(x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
				}
			}
		}
		if(max==0){
			System.out.println(1);
			return;
		}else{
			System.out.println(Math.sqrt(max)+2);
		}


	}
	static class UnionFind{
		int[] f;
		UnionFind(int size){
			f=new int[size];
			Arrays.fill(f, -1);
		}
		boolean setUnion(int x,int y){
			x=root(x);
			y=root(y);
			if(x!=y){
				if(f[x]>f[y]){
					int d=x;
					x=y;
					y=d;
				}
				f[x]+=f[y];
				f[y]=x;
			}
			return x!=y;
		}
		int root(int x){
			return f[x]<0?x:root(f[x]);
		}

	}
}

0