結果

問題 No.168 ものさし
ユーザー take4yotake4yo
提出日時 2020-09-18 23:24:42
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,230 bytes
コンパイル時間 408 ms
コンパイル使用メモリ 87,028 KB
実行使用メモリ 76,448 KB
最終ジャッジ日時 2023-09-04 11:36:48
合計ジャッジ時間 3,950 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

import math
N = int(input())
MAXDIST = 9*10**18 + 1

pos = []
for i in range(N):
    x, y = map(int, input().split())
    pos.append((x, y))

def distance(a, b):
    x0, y0 = pos[a]
    x1, y1 = pos[b]
    dd = (x1 - x0)*(x1 - x0) + (y1 - y0)*(y1 - y0)
    #return math.sqrt(dd)
    return dd

def prim():
    parent = [-1]*(N+1)
    intree = [0]*(N+1)
    dist = [MAXDIST]*(N+1)


    src = 0
    dist[src] = 0
    while src >= 0 and src != N-1:
        intree[src] = 1
        mind = MAXDIST
        nxt = -1
        for k in range(N):
            if intree[k] == 0:
                dd = distance(src, k)
                if dist[k] > dist[src] + dd:
                    dist[k] = dist[src] + dd
                    parent[k] = src
                if dist[k] < mind:
                    mind = dist[k]
                    nxt = k
        #if nxt >= 0: parent[nxt] = src
        src = nxt

    if src < 0: #not found??
        return MAXDIST

    #find max
    ans = 0
    while src != 0:
        pp = parent[src]
        dd = distance(src, pp)
        if ans < dd:
            ans = dd

        src = pp

    return ans

prm = prim()
ans = math.sqrt(prm)
while ans*ans < prm:
    ans = ans + 1

ans = int(ans/10) * 10
print(ans)
0