結果

問題 No.707 書道
コンテスト
ユーザー flippergo
提出日時 2026-04-25 10:25:19
言語 PyPy3
(7.3.23 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 76 ms / 2,000 ms
+ 205µs
コード長 447 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 75 ms
コンパイル使用メモリ 80,768 KB
実行使用メモリ 78,848 KB
最終ジャッジ日時 2026-09-12 10:58:17
合計ジャッジ時間 1,786 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 6
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

H,W = map(int, input().split())
def dist(a,b,x,y):
    return ((a-x)**2+(b-y)**2)**0.5
pos = {}
for i in range(1,H+1):
    pos[(i,0)] = 0
    pos[(i,W+1)] = 0
for j in range(1,W+1):
    pos[(0,j)] = 0
    pos[(H+1,j)] = 0
for i in range(H):
    s = input()
    for j in range(W):
        if s[j]=="1":
            for y,x in pos:
                pos[(y,x)] += dist(i+1,j+1,y,x)
ans = 10**10
for y,x in pos:
    ans = min(ans,pos[(y,x)])
print(ans)
0