結果

問題 No.26 シャッフルゲーム
ユーザー harhogefooharhogefoo
提出日時 2016-10-05 10:34:44
言語 Ruby
(3.2.2)
結果
AC  
実行時間 85 ms / 5,000 ms
コード長 245 bytes
コンパイル時間 178 ms
コンパイル使用メモリ 11,400 KB
実行使用メモリ 15,228 KB
最終ジャッジ日時 2023-08-13 23:11:51
合計ジャッジ時間 1,868 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
15,128 KB
testcase_01 AC 81 ms
15,228 KB
testcase_02 AC 85 ms
15,212 KB
testcase_03 AC 79 ms
15,036 KB
testcase_04 AC 79 ms
14,996 KB
testcase_05 AC 80 ms
15,088 KB
testcase_06 AC 81 ms
15,100 KB
testcase_07 AC 80 ms
15,216 KB
testcase_08 AC 81 ms
15,032 KB
testcase_09 AC 82 ms
15,132 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n = gets.to_i
m = gets.to_i

cups = Array.new(3, 0)
cups[n-1] = 1

m.times do
  p, q = gets.chomp.split(" ").map(&:to_i)
  p -= 1; q-= 1
  next if cups[p] == cups[q]
  tmp = cups[p]
  cups[p] = cups[q]
  cups[q] = tmp
end

puts cups.index(1) + 1
0