結果

問題 No.707 書道
ユーザー yamaghyamagh
提出日時 2018-07-31 20:07:53
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 747 bytes
コンパイル時間 62 ms
コンパイル使用メモリ 11,868 KB
実行使用メモリ 20,168 KB
最終ジャッジ日時 2023-10-19 20:32:56
合計ジャッジ時間 1,796 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 88 ms
16,044 KB
testcase_01 AC 89 ms
16,044 KB
testcase_02 AC 114 ms
17,364 KB
testcase_03 AC 86 ms
16,044 KB
testcase_04 WA -
testcase_05 AC 160 ms
19,060 KB
testcase_06 AC 192 ms
19,928 KB
testcase_07 AC 227 ms
20,168 KB
testcase_08 AC 91 ms
16,196 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

H,W = gets.split.map{|m|m.to_i}
P = $<.read.split("\n").map{|m|m.split('').map{|n|n.to_i}}
#H,W,P = 1,1,[1]

p 0 if P.inject(:+)==0

#puts "#{H} #{W}"
#P.each{|e|p e}
#puts '---'

memo = Array.new(H+2).map{Array.new(W+2, 0.0)}
#memo.each{|e|p e}

for y in 0..H+1
  for x in 0..W+1
    next if [*1..H].include?(y) and [*1..W].include?(x)
    #puts "x,y = #{x},#{y}"
    for k in 0..H-1
      for j in 0..W-1
        next if P[k][j] == 0
        #puts "j,k = #{j+1},#{k+1}"
        a = Math.sqrt( (x-(j+1))**2 + (y-(k+1))**2 )
        memo[y][x] += a
        #puts "memo[#{y}][#{x}] += Math.sqrt( (#{x}-#{j+1})**2 + (#{y}-#{k+1})**2 ) = #{a}"
      end
    end
    #puts ''
  end
end

#puts '---'
#memo.each{|e|p e}

puts memo.flatten.sort.uniq[1]

0