結果
問題 | No.707 書道 |
ユーザー | 💕💖💞 |
提出日時 | 2018-08-03 00:42:29 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 917 bytes |
コンパイル時間 | 250 ms |
コンパイル使用メモリ | 11,908 KB |
実行使用メモリ | 42,484 KB |
最終ジャッジ日時 | 2023-10-19 21:13:44 |
合計ジャッジ時間 | 8,382 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 483 ms
42,360 KB |
testcase_01 | AC | 481 ms
42,360 KB |
testcase_02 | AC | 535 ms
42,360 KB |
testcase_03 | AC | 483 ms
42,360 KB |
testcase_04 | RE | - |
testcase_05 | AC | 624 ms
42,360 KB |
testcase_06 | AC | 693 ms
42,360 KB |
testcase_07 | AC | 775 ms
42,360 KB |
testcase_08 | AC | 491 ms
42,360 KB |
ソースコード
import numpy as np import math (height, width) = map(int, input().split()) b = np.zeros((height+2, width+2)) for h in range(height): for w, ch in enumerate(input()): if ch == '1': b[h+1,w+1] = 1.0 key_l2 = {} for ww in [0, width+1]: for h in range(1, height+1): w = ww key = (h,w) for h2 in range(1, height+1): for w2 in range(1, width+1): if b[h2, w2] != 1.0: continue if key_l2.get(key) is None: key_l2[key] = 0.0 key_l2[key] += math.sqrt( (h - h2)**2 + (w - w2)**2 ) for hh in [0, height+1]: for w in range(1, width+1): h = hh key = (h,w) for h2 in range(1, height+1): for w2 in range(1, width+1): if b[h2, w2] != 1.0: continue if key_l2.get(key) is None: key_l2[key] = 0.0 key_l2[key] += math.sqrt( (h - h2)**2 + (w - w2)**2 ) print(min([f for key, f in key_l2.items()]))