結果

問題 No.707 書道
ユーザー MineMine
提出日時 2020-09-15 23:10:20
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 570 bytes
コンパイル時間 178 ms
コンパイル使用メモリ 10,880 KB
実行使用メモリ 8,836 KB
最終ジャッジ日時 2023-09-04 03:05:36
合計ジャッジ時間 1,484 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 21 ms
8,736 KB
testcase_01 AC 20 ms
8,724 KB
testcase_02 AC 48 ms
8,836 KB
testcase_03 AC 20 ms
8,568 KB
testcase_04 RE -
testcase_05 AC 99 ms
8,760 KB
testcase_06 AC 136 ms
8,812 KB
testcase_07 AC 185 ms
8,800 KB
testcase_08 AC 23 ms
8,712 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict
h, w = map(int, input().split())
p = [input() for i in range(h)]
black = []
for i in range(h):
    for g in range(w):
        if p[i][g] == "1":
            black.append((i+1, g+1))

red = defaultdict(float)
for i in range(1, h+1):
    for x, y in black:
        red[(i, 0)] += ((x-i)**2 + (y)**2)**0.5
        red[(i, w+1)] += ((x-i)**2 + (y-w-1)**2)**0.5


for i in range(1, w+1):
    for x, y in black:
        red[(0, i)] += ((x)**2 + (y-i)**2)**0.5
        red[(h+1, i)] += ((x-h-1)**2 + (y-i)**2)**0.5

print(min(red.values()))
0