結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 333 ms
56,300 KB
testcase_01 AC 152 ms
54,352 KB
testcase_02 AC 150 ms
54,368 KB
testcase_03 AC 150 ms
54,280 KB
testcase_04 AC 150 ms
54,240 KB
testcase_05 AC 148 ms
54,240 KB
testcase_06 WA -
testcase_07 AC 150 ms
54,356 KB
testcase_08 AC 149 ms
54,400 KB
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 227 ms
55,640 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=(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((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j])<=mid*mid*100){
							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