結果
| 問題 |
No.707 書道
|
| コンテスト | |
| ユーザー |
_polarbear08
|
| 提出日時 | 2018-08-03 05:38:26 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 803 bytes |
| コンパイル時間 | 95 ms |
| コンパイル使用メモリ | 12,800 KB |
| 実行使用メモリ | 10,752 KB |
| 最終ジャッジ日時 | 2024-09-19 17:19:36 |
| 合計ジャッジ時間 | 834 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | RE * 3 |
| other | RE * 6 |
ソースコード
from math import sqrt
def sum_dist(H: int, W: int, st: tuple) -> int:
global P
dist = 0
for w in range(1,W+1):
for h in range(1,H+1):
if P[h-1][w-1] == 1:
dist += sqrt((st[0]-w)**2 + (st[1]-h)**2)
return dist
file = open("sampleyukico707.txt", "r")
H,W = map(int, input().split())
P = []
for i in range(H):
P.append([int(p) for p in list(input().rstrip())])
INF = float("inf")
ans = INF
for w in range(1,W+1):
ans_temp = sum_dist(H,W,(w,0))
ans = min(ans, ans_temp)
ans_temp = sum_dist(H,W,(w,H+1))
ans = min(ans, ans_temp)
for h in range(1,H+1):
ans_temp = sum_dist(H,W,(0,h))
ans = min(ans, ans_temp)
ans_temp = sum_dist(H,W,(W+1,h))
ans = min(ans, ans_temp)
print(ans)
_polarbear08