結果

問題 No.168 ものさし
ユーザー TawaraTawara
提出日時 2015-09-05 05:26:02
言語 PyPy2
(7.3.15)
結果
TLE  
実行時間 -
コード長 725 bytes
コンパイル時間 134 ms
コンパイル使用メモリ 77,808 KB
実行使用メモリ 93,888 KB
最終ジャッジ日時 2023-09-26 08:42:35
合計ジャッジ時間 10,384 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,582 ms
93,888 KB
testcase_01 AC 134 ms
81,400 KB
testcase_02 AC 135 ms
81,568 KB
testcase_03 AC 134 ms
81,328 KB
testcase_04 AC 135 ms
81,532 KB
testcase_05 AC 132 ms
81,116 KB
testcase_06 AC 138 ms
81,112 KB
testcase_07 AC 131 ms
81,196 KB
testcase_08 AC 131 ms
81,556 KB
testcase_09 AC 267 ms
83,688 KB
testcase_10 AC 401 ms
85,948 KB
testcase_11 AC 1,441 ms
91,276 KB
testcase_12 TLE -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

from heapq import heappop as hpop, heappush as hpush
from decimal import Decimal
def dist(p1, p2):
	d = (Decimal((p1[0]-p2[0])**2 + (p1[1]-p2[1])**2)).sqrt()
	i_d = int(d)
	return i_d + (d>i_d)
def dijkstra (s, t, L, n):
	MAX = dist(xy[s],xy[t])
	d = [MAX for i in range(n)]
	Q = list()
	d[s] = 0
	hpush(Q,(0,s))
	while Q:
		tmp = hpop(Q)
		if tmp[1] == t:
			break
		for v in L[tmp[1]]:
			if tmp[0] > v[0]:
				tmpd = tmp[0]
			else:
				tmpd = v[0]
			if tmpd < d[v[1]]:
				d[v[1]] = tmpd
				hpush(Q,(tmpd,v[1]))
	return d[t]

N = int(raw_input())
xy = [map(int,raw_input().split()) for i in xrange(N)]
l = [[(dist(xy[i],xy[j]),j) for j in xrange(N) if j != i] for i in xrange(N)]
print (dijkstra(0,N-1,l,N)+9) / 10 * 10
0