結果

問題 No.157 2つの空洞
ユーザー 👑 hos.lyrichos.lyric
提出日時 2015-02-27 01:58:30
言語 Ruby
(3.3.0)
結果
AC  
実行時間 159 ms / 2,000 ms
コード長 339 bytes
コンパイル時間 193 ms
コンパイル使用メモリ 11,272 KB
実行使用メモリ 15,352 KB
最終ジャッジ日時 2023-09-06 03:22:33
合計ジャッジ時間 3,131 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
15,112 KB
testcase_01 AC 82 ms
15,160 KB
testcase_02 AC 79 ms
15,132 KB
testcase_03 AC 80 ms
15,284 KB
testcase_04 AC 79 ms
15,228 KB
testcase_05 AC 82 ms
15,296 KB
testcase_06 AC 85 ms
15,148 KB
testcase_07 AC 79 ms
15,140 KB
testcase_08 AC 80 ms
15,228 KB
testcase_09 AC 82 ms
15,264 KB
testcase_10 AC 79 ms
15,264 KB
testcase_11 AC 86 ms
15,352 KB
testcase_12 AC 91 ms
15,352 KB
testcase_13 AC 100 ms
15,036 KB
testcase_14 AC 122 ms
15,148 KB
testcase_15 AC 124 ms
15,156 KB
testcase_16 AC 126 ms
15,276 KB
testcase_17 AC 159 ms
15,256 KB
testcase_18 AC 119 ms
15,264 KB
testcase_19 AC 119 ms
15,192 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n,m=gets.split.map &:to_i
a=(1..m).map{gets}
(0...m).any?{|x|(0...n).any?{|y|q=(b=a[x][y]==?.)?[x,y]:[]
(x=q.shift
y=q.shift
m.times{|z|n.times{|w|(a[z][w]=?!;q+=[z,w])if (x-z).abs+(y-w).abs<2&&a[z][w]==?.}})while[]!=q
b}}
c=99
m.times{|x|n.times{|y|m.times{|z|n.times{|w|c=[c,(x-z).abs+(y-w).abs-1].min if a[x][y]==?!&&a[z][w]==?.}}}}
p c
0