結果

問題 No.168 ものさし
ユーザー roiti46roiti46
提出日時 2015-03-20 00:14:37
言語 PyPy2
(7.3.15)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,117 bytes
コンパイル時間 1,821 ms
コンパイル使用メモリ 77,376 KB
実行使用メモリ 299,052 KB
最終ジャッジ日時 2023-09-11 08:55:05
合計ジャッジ時間 17,950 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 521 ms
120,756 KB
testcase_01 AC 74 ms
76,872 KB
testcase_02 AC 74 ms
76,948 KB
testcase_03 AC 73 ms
76,828 KB
testcase_04 AC 74 ms
76,888 KB
testcase_05 AC 75 ms
76,776 KB
testcase_06 AC 88 ms
79,596 KB
testcase_07 AC 74 ms
77,136 KB
testcase_08 AC 73 ms
76,828 KB
testcase_09 AC 132 ms
80,440 KB
testcase_10 AC 163 ms
81,888 KB
testcase_11 AC 444 ms
100,060 KB
testcase_12 AC 1,308 ms
291,828 KB
testcase_13 AC 1,863 ms
299,052 KB
testcase_14 AC 1,911 ms
296,348 KB
testcase_15 AC 90 ms
79,820 KB
testcase_16 AC 125 ms
80,416 KB
testcase_17 AC 146 ms
80,664 KB
testcase_18 AC 214 ms
86,860 KB
testcase_19 AC 1,886 ms
293,236 KB
testcase_20 TLE -
testcase_21 TLE -
testcase_22 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import math
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

def dijkstra():
    d = [inf]*N
    used = [False]*N
    d[0] = 0
    while 1:
        v = -1
        for u in xrange(N):
            if not used[u] and (v == -1 or d[u] < d[v]): v = u
        if v == -1: break
        used[v] = True
        for u in xrange(N):
            d[u] = min(d[u], d[v]+D[v][u])
    return d[N-1]
    
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)]
dset = sorted(list(set([_D[i][j] for i in xrange(N) for j in xrange(N)])))
ans = max(dset)
l,p,r = 0,len(dset)/2,len(dset)
for loop in xrange(50):
    D = [[_D[i][j] if _D[i][j] <= dset[p] else inf for i in xrange(N)] for j in xrange(N)]
    if dijkstra() < inf:
        ans = min(ans,dset[p])
        r = p
    else:
        l = p
    p = (r+l)/2
print ans
0