結果
問題 | No.168 ものさし |
ユーザー | 37zigen |
提出日時 | 2016-03-25 16:30:49 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 570 ms / 2,000 ms |
コード長 | 1,388 bytes |
コンパイル時間 | 3,247 ms |
コンパイル使用メモリ | 73,788 KB |
実行使用メモリ | 61,908 KB |
最終ジャッジ日時 | 2023-08-25 21:01:14 |
合計ジャッジ時間 | 10,311 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 303 ms
57,760 KB |
testcase_01 | AC | 124 ms
53,836 KB |
testcase_02 | AC | 121 ms
55,620 KB |
testcase_03 | AC | 122 ms
56,064 KB |
testcase_04 | AC | 121 ms
55,692 KB |
testcase_05 | AC | 121 ms
55,424 KB |
testcase_06 | AC | 125 ms
56,236 KB |
testcase_07 | AC | 122 ms
56,264 KB |
testcase_08 | AC | 122 ms
56,208 KB |
testcase_09 | AC | 179 ms
57,348 KB |
testcase_10 | AC | 230 ms
58,084 KB |
testcase_11 | AC | 390 ms
57,800 KB |
testcase_12 | AC | 494 ms
60,020 KB |
testcase_13 | AC | 570 ms
59,848 KB |
testcase_14 | AC | 549 ms
61,908 KB |
testcase_15 | AC | 127 ms
55,832 KB |
testcase_16 | AC | 173 ms
57,420 KB |
testcase_17 | AC | 187 ms
57,412 KB |
testcase_18 | AC | 230 ms
57,576 KB |
testcase_19 | AC | 467 ms
59,768 KB |
testcase_20 | AC | 473 ms
59,248 KB |
testcase_21 | AC | 456 ms
59,672 KB |
testcase_22 | AC | 478 ms
59,772 KB |
ソースコード
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=200000000L; long low=0L; 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*10L&&Math.abs(y[i]-y[j])<=mid*10L){ long len2=(x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]); if(len2<=mid*mid*100L){ ds.setUnion(i, j); } } } } if(ds.setUnion(0,n-1)==false){ upper=mid; }else{ low=mid; } } System.out.println(upper*10); sc.close(); } public static class DJSet{ int[] f; public DJSet(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]); } int count(){ int cnt=0; for(int d:f){ if(d<0)cnt++; } return cnt; } } }