結果

問題 No.168 ものさし
ユーザー noko2250noko2250
提出日時 2015-03-20 04:27:50
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,046 bytes
コンパイル時間 1,281 ms
コンパイル使用メモリ 87,000 KB
実行使用メモリ 315,460 KB
最終ジャッジ日時 2023-09-11 09:00:16
合計ジャッジ時間 6,914 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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


def dist(a, b, c, d):
    d = ((a-b)**2 + (c-d)**2)**0.5
    if d-int(d) > 0:
        if int(d) % 10 == 0:
            return int(d)
        else:
            return int(d) + 10 - (int(d) % 10)


def main():
    n = int(input())
    x, y = [0] * n, [0] * n
    for i in range(n):
        [x[i], y[i]] = map(int, input().split())

    L = [[0] * n for _ in range(n)]
    for i in range(n):
        for j in range(i + 1, n):
            L[i][j] = L[j][i] = dist(x[i], x[j], y[i], y[j])

    que = PriorityQueue()
    S, G = 0, n-1
    que.put([0, [S]])
    ans = 10**9
    dm = [10**9] * n

    while not que.empty():
        e, v = que.get()
        t = 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