結果

問題 No.769 UNOシミュレータ
ユーザー Takuya NoguchiTakuya Noguchi
提出日時 2019-02-02 22:19:03
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 974 bytes
コンパイル時間 95 ms
コンパイル使用メモリ 7,424 KB
実行使用メモリ 54,916 KB
最終ジャッジ日時 2024-05-02 00:26:39
合計ジャッジ時間 6,326 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 93 ms
12,160 KB
testcase_01 AC 95 ms
12,160 KB
testcase_02 AC 91 ms
12,160 KB
testcase_03 AC 94 ms
12,288 KB
testcase_04 WA -
testcase_05 AC 96 ms
12,416 KB
testcase_06 AC 97 ms
12,416 KB
testcase_07 AC 96 ms
12,416 KB
testcase_08 AC 98 ms
12,288 KB
testcase_09 WA -
testcase_10 AC 111 ms
13,312 KB
testcase_11 AC 106 ms
13,312 KB
testcase_12 WA -
testcase_13 AC 239 ms
27,648 KB
testcase_14 AC 237 ms
27,648 KB
testcase_15 WA -
testcase_16 AC 378 ms
38,912 KB
testcase_17 WA -
testcase_18 AC 512 ms
54,660 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 515 ms
54,760 KB
testcase_22 AC 91 ms
12,288 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N, M = gets.split.map(&:to_i)
l = readlines.map(&:chomp)

card_nums, draw_card_nums = Hash.new(0), Hash.new(0)
stack_card_num, skip, prev_op, increment = 0, false, nil, 1
current_user_index = 0

loop do
  if skip
    current_user_index = (current_user_index + increment) % N
    skip = false
    next
  end

  op = l.shift

  if op != 'drawtwo' && prev_op == 'drawtwo' ||
     op != 'drawfour' && prev_op == 'drawfour'
    draw_card_nums[current_user_index] += stack_card_num
    current_user_index = (current_user_index + increment) % N
  end

  case op
  when 'drawtwo', 'drawfour'
    stack_card_num += (op == 'drawtwo' ? 2 : 4)
  when 'reverse'
    increment = -increment
  when 'skip'
    skip = true
  end

  card_nums[current_user_index] += 1

  break if l.empty?

  prev_op = op
  current_user_index = (current_user_index + increment) % N
end

card_num = card_nums[current_user_index] - draw_card_nums[current_user_index]
puts "#{current_user_index + 1} #{card_num}"
0