結果

問題 No.13 囲みたい!
ユーザー 👑 hos.lyrichos.lyric
提出日時 2015-03-01 21:11:36
言語 Ruby
(3.3.0)
結果
AC  
実行時間 95 ms / 5,000 ms
コード長 268 bytes
コンパイル時間 41 ms
コンパイル使用メモリ 11,508 KB
実行使用メモリ 15,764 KB
最終ジャッジ日時 2023-08-27 05:29:44
合計ジャッジ時間 2,342 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 83 ms
15,084 KB
testcase_01 AC 86 ms
15,124 KB
testcase_02 AC 85 ms
15,172 KB
testcase_03 AC 95 ms
15,588 KB
testcase_04 AC 86 ms
15,752 KB
testcase_05 AC 93 ms
15,588 KB
testcase_06 AC 93 ms
15,764 KB
testcase_07 AC 92 ms
15,488 KB
testcase_08 AC 93 ms
15,700 KB
testcase_09 AC 92 ms
15,668 KB
testcase_10 AC 83 ms
15,080 KB
testcase_11 AC 88 ms
15,624 KB
testcase_12 AC 84 ms
15,300 KB
testcase_13 AC 85 ms
15,244 KB
testcase_14 AC 85 ms
15,500 KB
testcase_15 AC 83 ms
15,268 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

def r u;u==$p[u]?u:$p[u]=r($p[u]);end
n,m=gets.split.map &:to_i
a=(1..m).map{gets.split.map(&:to_i)+[0]}+[[0]*n]
$p=(0...m*n).to_a
print (0...m*n).any?{|z|x=z/n;y=z%n
  [[x+1,y],[x,y+1]].any?{|e,f|
    a[x][y]==a[e][f]&&($p[u=r(z)]=r e*n+f)==u
  }
}?'':'im','possible'
0