結果
問題 | No.769 UNOシミュレータ |
ユーザー | gemmaro |
提出日時 | 2020-02-19 12:21:05 |
言語 | Ruby (3.3.0) |
結果 |
WA
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 2,109 bytes |
コンパイル時間 | 78 ms |
コンパイル使用メモリ | 7,424 KB |
実行使用メモリ | 34,560 KB |
最終ジャッジ日時 | 2024-05-02 00:44:42 |
合計ジャッジ時間 | 5,645 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 77 ms
12,288 KB |
testcase_01 | AC | 73 ms
12,160 KB |
testcase_02 | AC | 74 ms
12,288 KB |
testcase_03 | AC | 76 ms
12,160 KB |
testcase_04 | AC | 81 ms
12,160 KB |
testcase_05 | AC | 79 ms
12,160 KB |
testcase_06 | AC | 80 ms
12,416 KB |
testcase_07 | AC | 87 ms
12,160 KB |
testcase_08 | AC | 90 ms
12,160 KB |
testcase_09 | AC | 101 ms
12,928 KB |
testcase_10 | AC | 99 ms
12,928 KB |
testcase_11 | AC | 91 ms
12,800 KB |
testcase_12 | AC | 206 ms
18,176 KB |
testcase_13 | AC | 213 ms
18,304 KB |
testcase_14 | AC | 205 ms
18,304 KB |
testcase_15 | AC | 338 ms
25,984 KB |
testcase_16 | AC | 338 ms
25,984 KB |
testcase_17 | AC | 336 ms
25,984 KB |
testcase_18 | AC | 465 ms
34,560 KB |
testcase_19 | AC | 460 ms
34,432 KB |
testcase_20 | AC | 459 ms
34,304 KB |
testcase_21 | AC | 470 ms
34,304 KB |
testcase_22 | WA | - |
コンパイルメッセージ
Syntax OK
ソースコード
# frozen_string_literal: true # # represent drunks situation # class Drunks def number if @prev2 suffer2 advance elsif @prev4 suffer4 advance end consume advance end def draw2 if @prev4 suffer4 advance end consume @bomb += 2 @prev2 = true advance end def draw4 if @prev2 suffer2 advance end consume @bomb += 4 @prev4 = true advance end def skip if @prev2 suffer2 advance elsif @prev4 suffer4 advance end consume advance advance end def reverse if @prev2 suffer2 advance elsif @prev4 suffer4 advance end @reverse = !@reverse consume advance end def winner previous winner_id = @turn + 1 winner_first_num = @members[@turn].original "#{winner_id} #{winner_first_num}" end private def initialize(num) @turn = 0 @reverse = false @prev2 = false @prev4 = false @bomb = 0 @members = Array.new(num) { Drunk.new } end def advance turn = @turn + (@reverse ? -1 : 1) @turn = turn % @members.size end def previous turn = @turn + (@reverse ? 1 : -1) @turn = turn % @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 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 # ----------------------------------- exec N, M = gets.chomp.split.map(&:to_i) LS = M.times.map do gets.chomp end drunks = Drunks.new(N) LS.each do |type| case type when 'number' drunks.number when 'drawtwo' drunks.draw2 when 'drawfour' drunks.draw4 when 'skip' drunks.skip when 'reverse' drunks.reverse end end puts(drunks.winner)