結果

問題 No.168 ものさし
ユーザー roiti46
提出日時 2015-03-20 00:37:52
言語 PyPy2
(7.3.15)
結果
AC  
実行時間 469 ms / 2,000 ms
コード長 816 bytes
コンパイル時間 210 ms
コンパイル使用メモリ 77,056 KB
実行使用メモリ 88,972 KB
最終ジャッジ日時 2024-12-24 06:59:10
合計ジャッジ時間 5,629 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

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
0