結果
| 問題 | No.769 UNOシミュレータ | 
| コンテスト | |
| ユーザー |  yuruhiya | 
| 提出日時 | 2020-07-30 11:46:03 | 
| 言語 | Crystal (1.14.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 49 ms / 2,000 ms | 
| コード長 | 1,116 bytes | 
| コンパイル時間 | 10,769 ms | 
| コンパイル使用メモリ | 297,068 KB | 
| 実行使用メモリ | 6,948 KB | 
| 最終ジャッジ日時 | 2024-06-30 20:50:49 | 
| 合計ジャッジ時間 | 12,277 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 23 | 
ソースコード
n, m = read_line.split.map &.to_i
index, reverse = 0, 1
draw_kind, draw_count = -1, 0
count = [0] * n
m.times do |time|
  l = read_line
  if draw_kind != -1 && [l, draw_kind] != ["drawtwo", 2] && [l, draw_kind] != ["drawfour", 4]
    count[index] -= draw_count
    draw_kind, draw_count = -1, 0
    index = (index + reverse) % n
  end
  # p! [l, index + 1, reverse, draw_kind, draw_count, count]
  reverse = 0 if time == m - 1
  case l
  when "number"
    count[index] += 1
    index = (index + reverse) % n
  when "drawtwo"
    if draw_kind == 2
      count[index] += 1
      draw_count += 2
    else
      count[index] += 1
      draw_kind, draw_count = 2, 2
    end
    index = (index + reverse) % n
  when "drawfour"
    if draw_kind == 4
      count[index] += 1
      draw_count += 4
    else
      count[index] += 1
      draw_kind, draw_count = 4, 4
    end
    index = (index + reverse) % n
  when "skip"
    count[index] += 1
    index = (index + reverse * 2) % n
  when "reverse"
    count[index] += 1
    reverse *= -1
    index = (index + reverse) % n
  end
end
puts [index + 1, count[index]].join(' ')
            
            
            
        