結果
問題 | No.769 UNOシミュレータ |
ユーザー | gemmaro |
提出日時 | 2020-04-29 08:42:39 |
言語 | Ruby (3.3.0) |
結果 |
AC
|
実行時間 | 588 ms / 2,000 ms |
コード長 | 1,723 bytes |
コンパイル時間 | 115 ms |
コンパイル使用メモリ | 7,424 KB |
実行使用メモリ | 34,432 KB |
最終ジャッジ日時 | 2024-11-27 14:50:15 |
合計ジャッジ時間 | 7,037 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 85 ms
12,032 KB |
testcase_01 | AC | 89 ms
12,032 KB |
testcase_02 | AC | 88 ms
12,160 KB |
testcase_03 | AC | 87 ms
12,160 KB |
testcase_04 | AC | 90 ms
12,032 KB |
testcase_05 | AC | 90 ms
12,160 KB |
testcase_06 | AC | 91 ms
12,032 KB |
testcase_07 | AC | 90 ms
12,160 KB |
testcase_08 | AC | 90 ms
12,032 KB |
testcase_09 | AC | 104 ms
12,544 KB |
testcase_10 | AC | 107 ms
12,544 KB |
testcase_11 | AC | 102 ms
12,544 KB |
testcase_12 | AC | 244 ms
18,176 KB |
testcase_13 | AC | 246 ms
18,176 KB |
testcase_14 | AC | 245 ms
18,048 KB |
testcase_15 | AC | 417 ms
25,984 KB |
testcase_16 | AC | 418 ms
25,856 KB |
testcase_17 | AC | 418 ms
26,112 KB |
testcase_18 | AC | 588 ms
34,432 KB |
testcase_19 | AC | 581 ms
34,176 KB |
testcase_20 | AC | 583 ms
34,176 KB |
testcase_21 | AC | 585 ms
34,304 KB |
testcase_22 | AC | 86 ms
12,032 KB |
コンパイルメッセージ
Syntax OK
ソースコード
# frozen_string_literal: true # # represent ds situation # class Drunks def number(last) suffer_prev consume advance unless last end def drawtwo(last) if @prev4 suffer4 advance end consume @bomb += 2 @prev2 = true advance unless last end def drawfour(last) if @prev2 suffer2 advance end consume @bomb += 4 @prev4 = true advance unless last end def skip(last) suffer_prev consume advance(2) unless last end def reverse(last) suffer_prev @reverse = !@reverse consume advance unless last end def winner [@turn + 1, @members[@turn].original].join(' ') end private def initialize(num) @turn = 0 @reverse = false @prev2 = false @prev4 = false @bomb = 0 @members = Array.new(num) { Drunk.new } end def advance(step = 1) @turn = (@turn + (@reverse ? -step : step)) % @members.size end def suffer2 @members[@turn].penalty += @bomb @bomb = 0 @prev2 = false end def suffer4 @members[@turn].penalty += @bomb @bomb = 0 @prev4 = false end def suffer_prev if @prev2 suffer2 advance elsif @prev4 suffer4 advance end end def consume @members[@turn].change += 1 end # # represent drunk # class Drunk attr_accessor :change, :penalty def original @change - @penalty end private def initialize @change = 0 @penalty = 0 end end end N, M = gets.chomp.split.map(&:to_i) LS = M.times.map { gets.chomp } ds = Drunks.new(N) LS.each_with_index { |t, i| ds.public_send(t, i == LS.size - 1) } RESULT = ds.winner puts RESULT