結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
15,272 KB
testcase_01 AC 78 ms
15,088 KB
testcase_02 AC 78 ms
15,340 KB
testcase_03 AC 79 ms
15,308 KB
testcase_04 AC 78 ms
15,392 KB
testcase_05 AC 79 ms
15,372 KB
testcase_06 AC 80 ms
15,304 KB
testcase_07 AC 80 ms
15,292 KB
testcase_08 AC 78 ms
15,024 KB
testcase_09 AC 83 ms
15,240 KB
testcase_10 AC 76 ms
15,168 KB
testcase_11 AC 86 ms
15,388 KB
testcase_12 AC 93 ms
15,392 KB
testcase_13 AC 96 ms
15,212 KB
testcase_14 AC 119 ms
15,168 KB
testcase_15 AC 123 ms
15,388 KB
testcase_16 AC 127 ms
15,384 KB
testcase_17 AC 160 ms
15,356 KB
testcase_18 AC 122 ms
15,212 KB
testcase_19 AC 124 ms
15,256 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