結果

問題 No.402 最も海から遠い場所
ユーザー LeonardoneLeonardone
提出日時 2016-07-23 04:34:10
言語 Ruby
(3.3.0)
結果
TLE  
実行時間 -
コード長 1,421 bytes
コンパイル時間 160 ms
コンパイル使用メモリ 7,552 KB
実行使用メモリ 30,364 KB
最終ジャッジ日時 2024-04-24 07:13:25
合計ジャッジ時間 12,732 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 94 ms
17,792 KB
testcase_01 AC 94 ms
12,416 KB
testcase_02 AC 131 ms
12,416 KB
testcase_03 AC 89 ms
12,160 KB
testcase_04 AC 92 ms
12,032 KB
testcase_05 AC 93 ms
12,288 KB
testcase_06 AC 93 ms
12,160 KB
testcase_07 AC 90 ms
12,032 KB
testcase_08 AC 91 ms
12,160 KB
testcase_09 AC 93 ms
12,160 KB
testcase_10 AC 92 ms
12,160 KB
testcase_11 AC 109 ms
12,288 KB
testcase_12 AC 98 ms
12,288 KB
testcase_13 AC 475 ms
12,544 KB
testcase_14 AC 251 ms
12,288 KB
testcase_15 AC 2,144 ms
13,312 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 + 2)] + ngs(H).map{|r| '.' + r + '.' } + ['.' * (W + 2)]

f = '.'
g = ','

d = 0
loop do
    c = 0
    (H + 2).times do |y|
        (W + 2).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 + 2).include? ey
                next if !(0...W + 2).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