結果
| 問題 | No.707 書道 |
| コンテスト | |
| ユーザー |
maspy
|
| 提出日時 | 2020-01-29 23:23:28 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 521 ms / 2,000 ms |
| コード長 | 639 bytes |
| 記録 | |
| コンパイル時間 | 225 ms |
| コンパイル使用メモリ | 12,288 KB |
| 実行使用メモリ | 44,228 KB |
| 最終ジャッジ日時 | 2024-09-16 03:06:32 |
| 合計ジャッジ時間 | 6,395 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 6 |
ソースコード
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np
H,W = map(int,readline().split())
P = np.frombuffer(read(),'S1').reshape(H,-1)[:,:W]
P = (P == b'1') * 1
def gen_position():
for x in range(H):
yield (x,-1)
yield (x,W)
for y in range(W):
yield (-1,y)
yield (H,y)
opt_value = 10 ** 18
for x,y in gen_position():
dx = np.arange(H) - x
dy = np.arange(W) - y
D = np.sqrt((dx*dx)[:,None] + (dy*dy)[None,:])
value = (D * P).sum()
if opt_value > value:
opt_value = value
print(opt_value)
maspy