結果

問題 No.168 ものさし
ユーザー noko2250noko2250
提出日時 2015-03-20 12:05:50
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,102 bytes
コンパイル時間 378 ms
コンパイル使用メモリ 86,928 KB
実行使用メモリ 101,172 KB
最終ジャッジ日時 2023-09-11 09:05:41
合計ジャッジ時間 6,848 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/c/Python34/python
# coding: utf-8

from queue import PriorityQueue
from decimal import *


def dist(i, j, xy):
    x1, y1 = xy[i]
    x2, y2 = xy[j]
    d = (x1-x2)**2+(y1-y2)**2
    if Decimal(d).sqrt() > int(Decimal(d).sqrt()):
        return int(d**0.5)+10-(int(d**0.5) % 10)
    else:
        if int(d**0.5) % 10 == 0:
            return int(d**0.5)
        else:
            return int(d**0.5)+10-(int(d**0.5) % 10)



def main():
    n = int(input())
    xy = [list(map(int, input().split())) for _ in range(n)]
    L = [[dist(i, j, xy) for i in range(n)] for j in range(n)]

    que = PriorityQueue()
    inf = 10**19
    S, G = 0, n-1
    que.put([0, [S]])
    ans = inf
    dm = [inf] * n
    while not que.empty():
        e, v = que.get()
        e, t = int(e), int(v[-1])
        dm[t] = min(dm[t], e)
        if t == G:
            ans = min(e, ans)
            continue
        for i in range(n):
            if i == t or dm[i] <= max(L[t][i], e):
                continue
            que.put([max(L[t][i], e), v+[i]])

    print(ans)
    return

if __name__ == '__main__':
    main()
0