結果

問題 No.26 シャッフルゲーム
ユーザー rkyrky
提出日時 2017-11-06 15:17:24
言語 Ruby
(3.3.0)
結果
AC  
実行時間 71 ms / 5,000 ms
コード長 528 bytes
コンパイル時間 76 ms
コンパイル使用メモリ 11,480 KB
実行使用メモリ 15,308 KB
最終ジャッジ日時 2023-08-15 18:53:04
合計ジャッジ時間 1,809 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 67 ms
15,120 KB
testcase_01 AC 67 ms
15,148 KB
testcase_02 AC 70 ms
15,156 KB
testcase_03 AC 66 ms
15,104 KB
testcase_04 AC 67 ms
15,056 KB
testcase_05 AC 67 ms
15,288 KB
testcase_06 AC 68 ms
15,308 KB
testcase_07 AC 71 ms
15,192 KB
testcase_08 AC 70 ms
15,152 KB
testcase_09 AC 69 ms
15,004 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:16: warning: assigned but unused variable - i
Syntax OK

ソースコード

diff #

class No26
	attr_accessor :currect, :test_case, :cups

	def initialize
		@currect, @test_case = gets.chomp.to_i, gets.chomp.to_i
		@cups = [0, 0, 0]
		@cups[@currect - 1] = 1
	end

	def swap!(ary, idx1, idx2)
		ary[idx1], ary[idx2] = ary[idx2], ary[idx1]
    ary
	end

	def run
		for i in 0...@test_case do
			location1, location2 = gets.chomp.split.map(&:to_i)
			self.swap!(@cups, location1 - 1, location2 - 1)
		end
	end
end

no26 = No26.new
no26.run
no26.cups.each.with_index{|value, element| puts element + 1 if value == 1}
0