結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 84 ms
15,080 KB
testcase_01 AC 85 ms
15,104 KB
testcase_02 AC 84 ms
15,056 KB
testcase_03 AC 97 ms
15,492 KB
testcase_04 AC 89 ms
15,540 KB
testcase_05 AC 97 ms
15,468 KB
testcase_06 AC 95 ms
15,728 KB
testcase_07 AC 97 ms
15,664 KB
testcase_08 AC 96 ms
15,616 KB
testcase_09 AC 96 ms
15,572 KB
testcase_10 AC 86 ms
15,020 KB
testcase_11 AC 92 ms
15,560 KB
testcase_12 AC 86 ms
15,012 KB
testcase_13 AC 88 ms
15,496 KB
testcase_14 AC 87 ms
15,416 KB
testcase_15 AC 83 ms
15,128 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}+[[]]
$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