結果
| 問題 |
No.707 書道
|
| コンテスト | |
| ユーザー |
nonokai10
|
| 提出日時 | 2018-09-30 17:11:38 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 111 ms / 2,000 ms |
| コード長 | 563 bytes |
| コンパイル時間 | 111 ms |
| コンパイル使用メモリ | 12,800 KB |
| 実行使用メモリ | 11,008 KB |
| 最終ジャッジ日時 | 2024-10-12 09:13:13 |
| 合計ジャッジ時間 | 1,369 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 6 |
ソースコード
import math
h, w = map(int, input().split())
p = [list(map(int, list(input().strip()))) for i in range(h)]
c = []
for i in range(h):
for j in range(w):
if p[i][j] == 1:
c.append((i+1,j+1))
cost = []
for i in range(1,h+1):
cost.append(sum([math.sqrt((x-i)**2 + y**2) for x, y in c]))
cost.append(sum([math.sqrt((x-i)**2 + (y-(w+1))**2) for x, y in c]))
for i in range(1,w+1):
cost.append(sum([math.sqrt(x**2 + (y-i)**2) for x, y in c]))
cost.append(sum([math.sqrt((x-(h+1))**2 + (y-i)**2) for x, y in c]))
print(min(cost))
nonokai10