結果

問題 No.707 書道
コンテスト
ユーザー pluto77
提出日時 2018-07-26 16:06:04
言語 PyPy2
(7.3.20)
コンパイル:
pypy2 -m py_compile _filename_
実行:
/usr/bin/pypy2 Main.pyc
結果
AC  
実行時間 70 ms / 2,000 ms
+ 447µs
コード長 399 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 245 ms
コンパイル使用メモリ 62,536 KB
実行使用メモリ 64,104 KB
最終ジャッジ日時 2026-10-14 15:38:37
合計ジャッジ時間 1,975 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge4_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 7
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#yuki707
import math

h,w=map(int,raw_input().split())
p=[]
q=[]
for i in xrange(h):
 p.append(raw_input())
for i in xrange(h):
 for j in xrange(w):
  if p[i][j]=='1':
   q.append((i+1,j+1))

res=float('inf')
for i in xrange(h+2):
 cols=range(1,w+1) if i==0 or i==h+1 else [0,w+1]
 for j in cols:
  temp=0
  for x,y in q:
   temp+=math.sqrt((i-x)**2+(j-y)**2)
  res=min(res,temp)
print "%.9f" % res
0