結果
| 問題 | No.707 書道 |
| コンテスト | |
| ユーザー |
maspy
|
| 提出日時 | 2020-01-29 23:22:08 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 639 bytes |
| 記録 | |
| コンパイル時間 | 192 ms |
| コンパイル使用メモリ | 12,544 KB |
| 実行使用メモリ | 44,860 KB |
| 最終ジャッジ日時 | 2024-09-16 03:05:56 |
| 合計ジャッジ時間 | 5,987 ms |
|
ジャッジサーバーID (参考情報) |
judge6 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 5 WA * 1 |
ソースコード
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(H):
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