結果

問題 No.707 書道
ユーザー sekihankamibanzsekihankamibanz
提出日時 2018-10-28 23:30:02
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 143 ms / 2,000 ms
コード長 739 bytes
コンパイル時間 137 ms
コンパイル使用メモリ 10,972 KB
実行使用メモリ 29,792 KB
最終ジャッジ日時 2023-08-12 08:11:35
合計ジャッジ時間 2,141 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 132 ms
29,492 KB
testcase_01 AC 139 ms
29,472 KB
testcase_02 AC 137 ms
29,608 KB
testcase_03 AC 133 ms
29,628 KB
testcase_04 AC 132 ms
29,620 KB
testcase_05 AC 139 ms
29,544 KB
testcase_06 AC 140 ms
29,748 KB
testcase_07 AC 143 ms
29,792 KB
testcase_08 AC 134 ms
29,512 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import numpy as np


height, width = [int(x) for x in input().split(' ')]
paint_place = []
length_lists = []

for y in range(1, height + 1):
    x_lists = [int(x) for x in input()]
    for x, i in enumerate(x_lists):
        if i == 1:
            paint_place.append([x + 1,y])
            
paint_place = np.array(paint_place)

if paint_place.any():
    for x in range(width + 2):
        for y in range(height + 2):
            if (((x == 0) or (x == width + 1)) and (1 <= y <= height)) or (((y == 0) or (y == height + 1)) and (1 <= x <= width)) :
                point = np. array([x, y])
                length_lists.append(np.sum(np.sqrt(np.sum(((paint_place - point) ** 2), axis=1))))
    print(min(length_lists))

else:
    print(0)
0