結果
問題 | No.197 手品 |
ユーザー |
|
提出日時 | 2016-01-21 20:58:31 |
言語 | Ruby (3.4.1) |
結果 |
AC
|
実行時間 | 98 ms / 1,000 ms |
コード長 | 502 bytes |
コンパイル時間 | 134 ms |
コンパイル使用メモリ | 7,424 KB |
実行使用メモリ | 12,288 KB |
最終ジャッジ日時 | 2024-07-20 03:45:38 |
合計ジャッジ時間 | 5,693 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 43 |
コンパイルメッセージ
Syntax OK
ソースコード
H = {} H[0] = [[0, 1, 2]] H[1] = [[0, 2, 1], [1, 0, 2]] H[2] = [[0, 1, 2], [1, 2, 0], [2, 0, 1]] H[3] = [[0, 2, 1], [1, 0, 2], [2, 1, 0]] def possible?(sb, n, sa) aa = n <= 1 ? H[n] : n % 2 == 0 ? H[2] : H[3] aa.each do |a| flg = true a.each.with_index do |j, i| if sb[j] != sa[i] then flg = false break end end return true if flg end return false end SB = gets.chomp N = gets.to_i SA = gets.chomp puts possible?(SB, N, SA) ? "FAILURE" : "SUCCESS"