結果
問題 | No.168 ものさし |
ユーザー | roiti46 |
提出日時 | 2015-03-20 00:37:52 |
言語 | PyPy2 (7.3.15) |
結果 |
AC
|
実行時間 | 537 ms / 2,000 ms |
コード長 | 816 bytes |
コンパイル時間 | 265 ms |
コンパイル使用メモリ | 77,748 KB |
実行使用メモリ | 88,728 KB |
最終ジャッジ日時 | 2023-08-25 20:46:05 |
合計ジャッジ時間 | 6,331 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 275 ms
84,016 KB |
testcase_01 | AC | 84 ms
78,340 KB |
testcase_02 | AC | 83 ms
78,340 KB |
testcase_03 | AC | 84 ms
78,780 KB |
testcase_04 | AC | 82 ms
78,744 KB |
testcase_05 | AC | 83 ms
78,612 KB |
testcase_06 | AC | 85 ms
78,592 KB |
testcase_07 | AC | 84 ms
78,676 KB |
testcase_08 | AC | 84 ms
78,616 KB |
testcase_09 | AC | 107 ms
80,620 KB |
testcase_10 | AC | 116 ms
80,476 KB |
testcase_11 | AC | 178 ms
83,456 KB |
testcase_12 | AC | 537 ms
87,632 KB |
testcase_13 | AC | 410 ms
87,896 KB |
testcase_14 | AC | 331 ms
87,964 KB |
testcase_15 | AC | 84 ms
78,584 KB |
testcase_16 | AC | 106 ms
80,452 KB |
testcase_17 | AC | 109 ms
80,296 KB |
testcase_18 | AC | 130 ms
81,064 KB |
testcase_19 | AC | 429 ms
88,728 KB |
testcase_20 | AC | 483 ms
88,580 KB |
testcase_21 | AC | 424 ms
88,036 KB |
testcase_22 | AC | 356 ms
87,872 KB |
ソースコード
from collections import deque inf = 10**12 def dist(i,j): x1,y1 = XY[i] x2,y2 = XY[j] d = (x1-x2)**2+(y1-y2)**2 if d-int(d**0.5)**2 > 0: return int(d**0.5)/10*10+10 else: if int(d**0.5)%10 == 0: return int(d**0.5) else: return int(d**0.5)/10*10+10 N = int(raw_input()) XY = [map(int,raw_input().split()) for i in xrange(N)] D = [[dist(i,j) for i in xrange(N)] for j in xrange(N)] ans = inf que = deque([[0,0]]) maxd = [inf]*N maxd[0] = 0 while que: i,d = que.popleft() if d >= ans: continue if i == N-1: ans = min(ans,d) continue for j in xrange(N): if i == j: continue if D[i][j] < maxd[j] and d < maxd[j]: maxd[j] = max(d,D[i][j]) que.append([j,maxd[j]]) print ans