結果

問題 No.168 ものさし
ユーザー 37zigen37zigen
提出日時 2016-03-25 15:45:50
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,352 bytes
コンパイル時間 2,281 ms
コンパイル使用メモリ 82,796 KB
実行使用メモリ 59,016 KB
最終ジャッジ日時 2024-04-09 23:52:09
合計ジャッジ時間 10,823 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 330 ms
56,340 KB
testcase_01 AC 151 ms
54,344 KB
testcase_02 AC 151 ms
54,388 KB
testcase_03 AC 152 ms
54,360 KB
testcase_04 AC 152 ms
54,240 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 146 ms
54,280 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 231 ms
56,408 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

package yukicoder168;
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();
		long[] x=new long[n];
		long[] y=new long[n];
		for(int i=0;i<n;i++){
			x[i]=sc.nextLong();
			y[i]=sc.nextLong();
		}

		long upper=200000000;
		long low=0;
		while(upper!=low&&upper!=low+1){
			System.err.println("upper "+upper);
			System.err.println("low "+low);
			long mid=(int)(upper+low)/2;
			DJSet ds=new DJSet(n);
			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])<=mid*10&&Math.abs(y[i]-y[j])<=mid*10){
						if(Math.sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]))<=mid*10){
							ds.setUnion(i, j);
						}
					}
				}
			}
			if(ds.count()==1){
				upper=mid;
			}else{
				low=mid;
			}
		}
		System.out.println(upper*10);
		sc.close();
	}
	static class DJSet{
		int[] d;
		DJSet(int size){
			d=new int[size];
			Arrays.fill(d, -1);
		}
		boolean setUnion(int x,int y){
			x=root(x);
			y=root(y);
			if(x!=y){
				if(d[x]<d[y]){
					int tmp=y;
					y=x;
					x=tmp;
				}
				d[y]+=d[x];
				d[x]=y;
			}
			return x!=y;
		}
		int root(int x){
			return d[x]<0?x:(d[x]=root(d[x]));
		}
		int count(){
			int cnt=0;
			for(int a:d){
				if(a<0)cnt++;
			}
			return cnt;
		}
	}
}
0