結果

問題 No.168 ものさし
ユーザー TawaraTawara
提出日時 2015-09-05 17:24:06
言語 Python2
(2.7.18)
結果
AC  
実行時間 781 ms / 2,000 ms
コード長 731 bytes
コンパイル時間 878 ms
コンパイル使用メモリ 6,540 KB
実行使用メモリ 143,164 KB
最終ジャッジ日時 2023-08-25 20:59:51
合計ジャッジ時間 7,762 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 246 ms
37,384 KB
testcase_01 AC 21 ms
7,672 KB
testcase_02 AC 21 ms
7,648 KB
testcase_03 AC 20 ms
7,572 KB
testcase_04 AC 21 ms
7,640 KB
testcase_05 AC 21 ms
7,880 KB
testcase_06 AC 21 ms
7,832 KB
testcase_07 AC 21 ms
7,704 KB
testcase_08 AC 21 ms
7,672 KB
testcase_09 AC 26 ms
8,140 KB
testcase_10 AC 41 ms
10,716 KB
testcase_11 AC 197 ms
33,996 KB
testcase_12 AC 565 ms
101,744 KB
testcase_13 AC 773 ms
143,164 KB
testcase_14 AC 668 ms
141,672 KB
testcase_15 AC 21 ms
7,572 KB
testcase_16 AC 24 ms
7,880 KB
testcase_17 AC 33 ms
9,092 KB
testcase_18 AC 57 ms
13,304 KB
testcase_19 AC 751 ms
137,240 KB
testcase_20 AC 698 ms
142,904 KB
testcase_21 AC 781 ms
142,992 KB
testcase_22 AC 721 ms
142,428 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from heapq import heappop as hpop, heappush as hpush
from decimal import Decimal
def sq_dist(p1, p2):
	return (p1[0]-p2[0])**2+(p1[1]-p2[1])**2
def solve(s, t, L, n):
	MAX = sq_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 = [[(sq_dist(xy[i],xy[j]),j) for j in xrange(N) if j != i] for i in xrange(N)]
max_d = Decimal(solve(0,N-1,l,N)).sqrt()
i_d = int(max_d)
print (i_d+(max_d>i_d)+9) / 10 * 10
0