結果

問題 No.707 書道
ユーザー tails1434tails1434
提出日時 2020-01-17 07:35:49
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 115 ms / 2,000 ms
コード長 755 bytes
コンパイル時間 564 ms
コンパイル使用メモリ 87,168 KB
実行使用メモリ 77,068 KB
最終ジャッジ日時 2023-09-07 18:41:38
合計ジャッジ時間 1,969 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,892 KB
testcase_01 AC 77 ms
72,056 KB
testcase_02 AC 95 ms
77,068 KB
testcase_03 AC 72 ms
71,384 KB
testcase_04 AC 73 ms
71,156 KB
testcase_05 AC 104 ms
77,048 KB
testcase_06 AC 108 ms
76,912 KB
testcase_07 AC 115 ms
76,944 KB
testcase_08 AC 79 ms
76,392 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
    H, W = map(int, input().split())
    P = list(input() for _ in range(H))
    ans = float('inf')
    
    for h1 in range(1,H+1):
        for w1 in [0,W+1]:
            tmp = 0
            for h in range(H):
                for w in range(W):
                    if P[h][w] == '1':
                        tmp += ((h + 1 - h1) ** 2 + (w + 1 - w1) ** 2) ** 0.5
            ans = min(ans, tmp)

    for w1 in range(1,W+1):
        for h1 in [0,H+1]:
            tmp = 0
            for h in range(H):
                for w in range(W):
                    if P[h][w] == '1':
                        tmp += ((h + 1 - h1) ** 2 + (w + 1 - w1) ** 2) ** 0.5
            ans = min(ans, tmp)

    print(ans)




if __name__ == "__main__":
    main()
0