結果

問題 No.168 ものさし
ユーザー yaoshimaxyaoshimax
提出日時 2015-03-20 00:00:35
言語 Python2
(2.7.18)
結果
AC  
実行時間 1,260 ms / 2,000 ms
コード長 866 bytes
コンパイル時間 404 ms
コンパイル使用メモリ 6,944 KB
実行使用メモリ 140,160 KB
最終ジャッジ日時 2024-06-06 14:46:21
合計ジャッジ時間 10,609 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 324 ms
35,072 KB
testcase_01 AC 11 ms
6,272 KB
testcase_02 AC 11 ms
6,272 KB
testcase_03 AC 11 ms
6,272 KB
testcase_04 AC 11 ms
6,144 KB
testcase_05 AC 11 ms
6,144 KB
testcase_06 AC 11 ms
6,272 KB
testcase_07 AC 11 ms
6,144 KB
testcase_08 AC 11 ms
6,272 KB
testcase_09 AC 19 ms
6,912 KB
testcase_10 AC 41 ms
9,216 KB
testcase_11 AC 261 ms
32,128 KB
testcase_12 AC 873 ms
98,432 KB
testcase_13 AC 1,260 ms
140,032 KB
testcase_14 AC 1,236 ms
140,032 KB
testcase_15 AC 11 ms
6,272 KB
testcase_16 AC 17 ms
6,656 KB
testcase_17 AC 30 ms
7,680 KB
testcase_18 AC 67 ms
11,776 KB
testcase_19 AC 1,182 ms
133,632 KB
testcase_20 AC 1,222 ms
140,160 KB
testcase_21 AC 1,258 ms
140,160 KB
testcase_22 AC 1,236 ms
140,032 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N=int(raw_input())
P=[map(int,raw_input().split()) for i in range(N)]
edge=[[] for i in range(N)]
for i in range(N):
    for j in range(N):
        if i!=j:
            dx=P[i][0]-P[j][0]
            dy=P[i][1]-P[j][1]
            edge[i].append((dx*dx+dy*dy,j))
for i in range(N):
    edge[i].sort()

left = 0
right = 200000000

while left+1 < right:
    mid=(left+right)/2
    dist=mid*10
    ok=False
    arrived=[False for i in range(N)]
    p=[0]
    arrived[0]=True
    while len(p)!=0 and ok==False:
        cur=p.pop()
        for d,nxt in edge[cur]:
            if d > dist*dist:
                break
            if arrived[nxt]:
                continue
            if nxt==N-1:
                ok=True
                break
            arrived[nxt]=True
            p.append(nxt)
    if ok:
        right = mid
    else:
        left=mid

print right*10
0