結果

問題 No.707 書道
ユーザー lloyzlloyz
提出日時 2022-06-21 22:59:31
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 94 ms / 2,000 ms
コード長 589 bytes
コンパイル時間 187 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 74,880 KB
最終ジャッジ日時 2024-04-23 01:24:04
合計ジャッジ時間 1,466 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 45 ms
52,096 KB
testcase_01 AC 46 ms
52,224 KB
testcase_02 AC 72 ms
68,096 KB
testcase_03 AC 41 ms
52,224 KB
testcase_04 AC 41 ms
52,352 KB
testcase_05 AC 91 ms
72,192 KB
testcase_06 AC 91 ms
73,600 KB
testcase_07 AC 94 ms
74,880 KB
testcase_08 AC 58 ms
62,464 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

h, w = map(int, input().split())
P = [list(map(int, list(input()))) for _ in range(h)]

ans = 10**18
for cy in [-1, h]:
    for cx in range(w):
        res = 0
        for i in range(h):
            for j in range(w):
                if P[i][j] == 1:
                    res += ((i - cy)**2 + (j - cx)**2)**0.5
        ans = min(ans, res)

for cx in [-1, w]:
    for cy in range(h):
        res = 0
        for i in range(h):
            for j in range(w):
                if P[i][j] == 1:
                    res += ((i - cy)**2 + (j - cx)**2)**0.5
        ans = min(ans, res)
print(ans)
0