結果

問題 No.26 シャッフルゲーム
ユーザー letrangerjpletrangerjp
提出日時 2017-06-04 21:50:03
言語 Ruby
(3.3.0)
結果
AC  
実行時間 78 ms / 5,000 ms
コード長 263 bytes
コンパイル時間 445 ms
コンパイル使用メモリ 11,884 KB
実行使用メモリ 16,284 KB
最終ジャッジ日時 2023-10-22 04:25:11
合計ジャッジ時間 1,656 ms
ジャッジサーバーID
(参考情報)
judge12 / judge9
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
16,108 KB
testcase_01 AC 76 ms
16,108 KB
testcase_02 AC 77 ms
16,284 KB
testcase_03 AC 73 ms
16,108 KB
testcase_04 AC 73 ms
16,108 KB
testcase_05 AC 72 ms
16,108 KB
testcase_06 AC 72 ms
16,232 KB
testcase_07 AC 77 ms
16,108 KB
testcase_08 AC 78 ms
16,248 KB
testcase_09 AC 76 ms
16,284 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N = gets.to_i
M = gets.to_i
Q = M.times.map{
  gets.split.take(2).map(&:to_i)
}

def f(a, query)
  if query.empty?
    a.index(&:odd?)
  else
    car, *cdr = query
    i, j = car
    a[i], a[j] = a[j], a[i]
    f(a, cdr)
  end
end

A = [0] * 4
A[N] = 1
p f(A, Q)
0