結果

問題 No.402 最も海から遠い場所
ユーザー LeonardoneLeonardone
提出日時 2016-07-23 04:31:00
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 1,389 bytes
コンパイル時間 163 ms
コンパイル使用メモリ 7,680 KB
実行使用メモリ 29,568 KB
最終ジャッジ日時 2024-04-24 07:12:53
合計ジャッジ時間 12,672 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 82 ms
17,664 KB
testcase_01 AC 82 ms
12,160 KB
testcase_02 AC 114 ms
12,416 KB
testcase_03 WA -
testcase_04 AC 82 ms
12,160 KB
testcase_05 AC 83 ms
12,288 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 85 ms
12,288 KB
testcase_09 AC 85 ms
12,416 KB
testcase_10 AC 89 ms
12,288 KB
testcase_11 AC 98 ms
12,288 KB
testcase_12 WA -
testcase_13 AC 454 ms
12,416 KB
testcase_14 AC 234 ms
12,416 KB
testcase_15 AC 2,068 ms
13,440 KB
testcase_16 TLE -
testcase_17 TLE -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

# yukicoder My Practice
# author: Leonardone @ NEETSDKASU
############################################################
def gs() gets.chomp end
def gi() gets.to_i end
def gf() gets.to_f end
def gss() gs.split end
def gis() gss.map(&:to_i) end
def gfs() gss.map(&:to_f) end
def nmapf(n,f) n.times.map{ __send__ f } end
def ngs(n) nmapf n,:gs end
def ngi(n) nmapf n,:gi end
def ngss(n) nmapf n,:gss end
def ngis(n) nmapf n,:gis end
def arr2d(h,w,v=0) h.times.map{[v] * w} end
def for2p(hr,wr,&pr) hr.each{|i|wr.each{|j| yield(i,j)}} end
def nsum(n) n * (n + 1) / 2 end
def vcount(d,r=Hash.new(0)) d.inject(r){|m,e| m[e]+=1;m} end
MV4 = [[0, 1], [1, 0], [0, -1], [-1, 0]]
MV8 = MV4 + [[1, 1], [-1, -1], [1, -1], [-1, 1]]
############################################################

H, W = gis
m = ['.' * W] + ngs(H).map{|r| '.' + r + '.' } + ['.' * W]

f = '.'
g = ','

d = 0
loop do
    c = 0
    H.times do |y|
        W.times do |x|
            next if m[y][x] != f
            m[y][x] = '_'
            MV8.each do |dy, dx|
                ey = y + dy
                ex = x + dx
                next if !(0...H).include? ey
                next if !(0...W).include? ex
                next if m[ey][ex] != '#'
                m[ey][ex] = g
                c += 1
            end
        end
    end
    f, g = g, f
    if c == 0
        break
    else
        d += 1
    end
end

puts d
0