結果
| 問題 | No.707 書道 |
| コンテスト | |
| ユーザー |
lam6er
|
| 提出日時 | 2025-03-20 21:19:47 |
| 言語 | PyPy3 (8.0.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 45 ms / 2,000 ms |
| + 988µs | |
| コード長 | 1,022 bytes |
| 記録 | |
| コンパイル時間 | 88 ms |
| コンパイル使用メモリ | 64,600 KB |
| 実行使用メモリ | 59,452 KB |
| 最終ジャッジ日時 | 2026-10-15 02:10:32 |
| 合計ジャッジ時間 | 1,853 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge5_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 7 |
ソースコード
import math
H, W = map(int, input().split())
dots = []
for y in range(1, H + 1):
line = input().strip()
for x in range(1, W + 1):
if line[x - 1] == '1':
dots.append((x, y))
if not dots:
print("0.00000000")
else:
min_total = float('inf')
positions = []
# Left edge: x=0, y from 1 to H
for y in range(1, H + 1):
positions.append((0, y))
# Right edge: x=W+1, y from 1 to H
for y in range(1, H + 1):
positions.append((W + 1, y))
# Top edge: y=0, x from 1 to W
for x in range(1, W + 1):
positions.append((x, 0))
# Bottom edge: y=H+1, x from 1 to W
for x in range(1, W + 1):
positions.append((x, H + 1))
for (sx, sy) in positions:
total = 0.0
for (x, y) in dots:
dx = sx - x
dy = sy - y
dist = math.sqrt(dx ** 2 + dy ** 2)
total += dist
if total < min_total:
min_total = total
print("{0:.8f}".format(min_total))
lam6er