結果

問題 No.707 書道
ユーザー nebukuro09nebukuro09
提出日時 2018-06-29 23:47:15
言語 PyPy2
(7.3.15)
結果
AC  
実行時間 92 ms / 2,000 ms
コード長 457 bytes
コンパイル時間 1,493 ms
コンパイル使用メモリ 77,508 KB
実行使用メモリ 79,196 KB
最終ジャッジ日時 2023-09-13 15:49:20
合計ジャッジ時間 2,963 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
76,212 KB
testcase_01 AC 76 ms
76,440 KB
testcase_02 AC 92 ms
79,064 KB
testcase_03 AC 74 ms
76,408 KB
testcase_04 AC 74 ms
76,176 KB
testcase_05 AC 88 ms
79,196 KB
testcase_06 AC 88 ms
79,036 KB
testcase_07 AC 92 ms
79,048 KB
testcase_08 AC 81 ms
79,088 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import math

H, W = map(int, raw_input().split())
A = [raw_input() for _ in xrange(H)]
B = []
for i in xrange(H):
    for j in xrange(W):
        if A[i][j] == '1':
            B.append((i+1, j+1))

ans = float('inf')
for i in xrange(H+2):
    cols = range(1, W+1) if i == 0 or i == H+1 else [0, W+1]
    for j in cols:
        tmp = 0
        for x, y in B:
            tmp += math.sqrt((i-x)**2 + (j-y)**2)
        ans = min(ans, tmp)

print "%.9f" % ans
0