結果

問題 No.707 書道
ユーザー pluto77pluto77
提出日時 2018-07-26 16:06:04
言語 Python2
(2.7.18)
結果
AC  
実行時間 99 ms / 2,000 ms
コード長 399 bytes
コンパイル時間 430 ms
コンパイル使用メモリ 6,688 KB
実行使用メモリ 6,100 KB
最終ジャッジ日時 2023-09-13 18:41:12
合計ジャッジ時間 1,673 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
6,100 KB
testcase_01 AC 11 ms
6,080 KB
testcase_02 AC 28 ms
5,992 KB
testcase_03 AC 11 ms
5,928 KB
testcase_04 AC 11 ms
5,944 KB
testcase_05 AC 54 ms
5,928 KB
testcase_06 AC 76 ms
5,964 KB
testcase_07 AC 99 ms
6,004 KB
testcase_08 AC 13 ms
6,008 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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