結果
問題 | No.168 ものさし |
ユーザー | しらっ亭 |
提出日時 | 2015-06-19 00:50:09 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,099 bytes |
コンパイル時間 | 76 ms |
コンパイル使用メモリ | 10,956 KB |
実行使用メモリ | 42,796 KB |
最終ジャッジ日時 | 2023-09-21 09:37:01 |
合計ジャッジ時間 | 5,192 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 220 ms
16,596 KB |
testcase_01 | AC | 17 ms
8,540 KB |
testcase_02 | WA | - |
testcase_03 | AC | 17 ms
8,424 KB |
testcase_04 | AC | 17 ms
8,448 KB |
testcase_05 | AC | 17 ms
8,500 KB |
testcase_06 | AC | 17 ms
8,620 KB |
testcase_07 | AC | 17 ms
8,632 KB |
testcase_08 | AC | 18 ms
8,524 KB |
testcase_09 | AC | 21 ms
8,240 KB |
testcase_10 | AC | 30 ms
9,176 KB |
testcase_11 | AC | 152 ms
15,456 KB |
testcase_12 | AC | 378 ms
30,692 KB |
testcase_13 | AC | 488 ms
39,552 KB |
testcase_14 | AC | 257 ms
38,044 KB |
testcase_15 | AC | 17 ms
8,640 KB |
testcase_16 | AC | 20 ms
8,220 KB |
testcase_17 | AC | 26 ms
8,588 KB |
testcase_18 | AC | 37 ms
10,160 KB |
testcase_19 | AC | 497 ms
41,828 KB |
testcase_20 | AC | 343 ms
42,664 KB |
testcase_21 | AC | 527 ms
42,160 KB |
testcase_22 | AC | 395 ms
42,796 KB |
ソースコード
from heapq import heappush, heappop import math def d2(p1, p2): return (p1[0] - p2[0]) ** 2 + (p1[1] - p2[1]) ** 2 def dij(n, ps): start = 0 goal = n - 1 d2mat = [[0] * n for i in range(n)] for i in range(n): for j in range(i + 1, n): d2mat[i][j] = d2mat[j][i] = d2(ps[i], ps[j]) d = [d2mat[start][i] for i in range(n)] hq = [] for i in range(n): heappush(hq, (d[i], i)) while hq: m, i = heappop(hq) if i == goal: return m for j in range(n): dij = d2mat[i][j] mj = max(m, dij) if d[j] > mj: d[j] = mj heappush(hq, (mj, j)) return d[goal] def solve(n, ps): ans = dij(n, ps) a2 = math.sqrt(ans) c = math.ceil(a2 / 10) return min(filter(lambda a: (a * 10) ** 2 > ans, [c - 1, c, c + 1])) * 10 def main(): n = int(input()) ps = [] for i in range(n): x, y = list(map(int, input().split())) ps.append((x, y)) print(solve(n, ps)) if __name__ == '__main__': main()