結果

問題 No.707 書道
ユーザー nadarenadare
提出日時 2018-06-29 22:58:00
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 166 ms / 2,000 ms
コード長 652 bytes
コンパイル時間 94 ms
コンパイル使用メモリ 10,940 KB
実行使用メモリ 35,356 KB
最終ジャッジ日時 2023-09-13 15:32:51
合計ジャッジ時間 2,372 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 126 ms
29,720 KB
testcase_01 AC 125 ms
29,760 KB
testcase_02 AC 166 ms
30,708 KB
testcase_03 AC 125 ms
29,776 KB
testcase_04 AC 125 ms
29,604 KB
testcase_05 AC 131 ms
32,192 KB
testcase_06 AC 135 ms
33,792 KB
testcase_07 AC 138 ms
35,356 KB
testcase_08 AC 125 ms
29,852 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# -*- coding: utf-8 -*-
import numpy as np

X = []
Y = []

H, W = map(int, input().split())

for h in range(1, H+1):
    for w, v in enumerate(map(int, input()), start=1):
        if v==0:
            continue
        X.append(w)
        Y.append(h)

gX = np.array(X, dtype=np.float64).reshape(1, -1)
gY = np.array(Y, dtype=np.float64).reshape(1, -1)

rX = np.array([0]*H + [W+1]*H + list(range(1, W+1)) + list(range(1, W+1)), dtype=np.float64).reshape(1, -1)
rY = np.array(list(range(1, H+1)) + list(range(1, H+1)) + [0]*W + [H+1]*W, dtype=np.float64).reshape(1, -1)

print(np.min(np.sum(np.sqrt(np.power(gX-rX.T, 2) + np.power(gY-rY.T, 2)), axis=1)))
0