結果

問題 No.707 書道
ユーザー Mine
提出日時 2020-09-15 23:10:20
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
RE  
実行時間 -
コード長 570 bytes
コンパイル時間 74 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 11,008 KB
最終ジャッジ日時 2024-06-22 02:49:14
合計ジャッジ時間 1,266 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 5 RE * 1
権限があれば一括ダウンロードができます

ソースコード

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