結果

問題 No.707 書道
ユーザー prd_xxxprd_xxx
提出日時 2018-06-29 22:49:45
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 136 ms / 2,000 ms
コード長 629 bytes
コンパイル時間 292 ms
コンパイル使用メモリ 86,732 KB
実行使用メモリ 77,220 KB
最終ジャッジ日時 2023-09-13 15:30:20
合計ジャッジ時間 1,769 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,044 KB
testcase_01 AC 71 ms
71,200 KB
testcase_02 AC 99 ms
76,852 KB
testcase_03 AC 69 ms
70,864 KB
testcase_04 AC 73 ms
71,172 KB
testcase_05 AC 111 ms
76,984 KB
testcase_06 AC 124 ms
77,220 KB
testcase_07 AC 136 ms
77,072 KB
testcase_08 AC 77 ms
76,040 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import math
H,W = map(int,input().split())
src = [[]]
src += ['0' + input() + '0' for i in range(H)]

ans = float('inf')
for px in (0,W+1):
    for py in range(1,H+1):
        tmp = 0
        for y in range(1,H+1):
            for x in range(1,W+1):
                if src[y][x] == '0': continue
                tmp += math.hypot(px-x, py-y)
        ans = min(ans, tmp)
for py in (0,H+1):
    for px in range(1,W+1):
        tmp = 0
        for y in range(1,H+1):
            for x in range(1,W+1):
                if src[y][x] == '0': continue
                tmp += math.hypot(px-x, py-y)
        ans = min(ans, tmp)
print(ans)
0