結果

問題 No.157 2つの空洞
ユーザー 👑 hos.lyrichos.lyric
提出日時 2015-02-27 02:24:33
言語 Ruby
(3.3.0)
結果
AC  
実行時間 173 ms / 2,000 ms
コード長 326 bytes
コンパイル時間 43 ms
コンパイル使用メモリ 11,464 KB
実行使用メモリ 15,416 KB
最終ジャッジ日時 2023-08-27 05:29:41
合計ジャッジ時間 3,435 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 91 ms
15,188 KB
testcase_01 AC 88 ms
15,300 KB
testcase_02 AC 83 ms
15,256 KB
testcase_03 AC 83 ms
15,096 KB
testcase_04 AC 86 ms
15,096 KB
testcase_05 AC 87 ms
15,136 KB
testcase_06 AC 92 ms
15,344 KB
testcase_07 AC 86 ms
15,128 KB
testcase_08 AC 84 ms
15,096 KB
testcase_09 AC 87 ms
15,136 KB
testcase_10 AC 85 ms
15,048 KB
testcase_11 AC 95 ms
15,252 KB
testcase_12 AC 115 ms
15,248 KB
testcase_13 AC 129 ms
15,368 KB
testcase_14 AC 139 ms
15,192 KB
testcase_15 AC 154 ms
15,176 KB
testcase_16 AC 173 ms
15,252 KB
testcase_17 AC 167 ms
15,316 KB
testcase_18 AC 166 ms
15,416 KB
testcase_19 AC 168 ms
15,248 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

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