結果

問題 No.96 圏外です。
ユーザー 37zigen37zigen
提出日時 2016-03-25 02:05:02
言語 Java21
(openjdk 21)
結果
TLE  
実行時間 -
コード長 1,272 bytes
コンパイル時間 2,227 ms
コンパイル使用メモリ 77,604 KB
実行使用メモリ 63,332 KB
最終ジャッジ日時 2024-04-09 23:45:00
合計ジャッジ時間 20,388 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 143 ms
54,432 KB
testcase_01 AC 143 ms
54,532 KB
testcase_02 AC 145 ms
54,252 KB
testcase_03 AC 129 ms
53,900 KB
testcase_04 AC 555 ms
61,884 KB
testcase_05 AC 661 ms
62,608 KB
testcase_06 AC 1,032 ms
63,332 KB
testcase_07 AC 1,644 ms
62,776 KB
testcase_08 AC 2,535 ms
62,348 KB
testcase_09 AC 3,696 ms
62,940 KB
testcase_10 TLE -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
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 #

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(Math.abs(x[i]-x[j])<=10&&Math.abs(y[i]-y[j])<=10){
					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(n==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