結果

問題 No.769 UNOシミュレータ
ユーザー 👑 obakyanobakyan
提出日時 2019-04-14 00:15:01
言語 Lua
(LuaJit 2.1.1696795921)
結果
AC  
実行時間 51 ms / 2,000 ms
コード長 1,998 bytes
コンパイル時間 33 ms
コンパイル使用メモリ 6,816 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-05-02 00:33:48
合計ジャッジ時間 1,360 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 1 ms
6,940 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 3 ms
6,940 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 4 ms
6,944 KB
testcase_10 AC 4 ms
6,944 KB
testcase_11 AC 4 ms
6,940 KB
testcase_12 AC 18 ms
6,940 KB
testcase_13 AC 18 ms
6,940 KB
testcase_14 AC 20 ms
6,940 KB
testcase_15 AC 36 ms
6,940 KB
testcase_16 AC 33 ms
6,944 KB
testcase_17 AC 33 ms
6,940 KB
testcase_18 AC 48 ms
6,944 KB
testcase_19 AC 50 ms
6,944 KB
testcase_20 AC 49 ms
6,944 KB
testcase_21 AC 51 ms
6,940 KB
testcase_22 AC 1 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, m = io.read("*n", "*n", "*l")
cards = {}
way = 1
prev_user = 1
current_user = 1
d2chain, d4chain = 0, 0

for i = 1, n do cards[i] = 0 end
for i_m = 1, m do
  s = io.read()
  if(0 < d2chain) then
    if(s == "drawtwo") then
      prev_user = current_user
      cards[current_user] = cards[current_user] + 1
      current_user = current_user + way
      d2chain = d2chain + 1
    else
      prev_user = current_user
      cards[current_user] = cards[current_user] - 2 * d2chain
      current_user = current_user + way
      d2chain = 0
    end
  end
  if(0 < d4chain) then
    if(s == "drawfour") then
      prev_user = current_user
      cards[current_user] = cards[current_user] + 1
      current_user = current_user + way
      d4chain = d4chain + 1
    else
      prev_user = current_user
      cards[current_user] = cards[current_user] - 4 * d4chain
      current_user = current_user + way
      d4chain = 0
    end
  end
  current_user = current_user % n
  if(current_user == 0) then current_user = n end
  if(s == "number") then
    prev_user = current_user
    cards[current_user] = cards[current_user] + 1
    current_user = current_user + way
  elseif(s == "skip") then
    prev_user = current_user
    cards[current_user] = cards[current_user] + 1
    current_user = current_user + way * 2
  elseif(s == "reverse") then
    prev_user = current_user
    cards[current_user] = cards[current_user] + 1
    way = -way
    current_user = current_user + way
  elseif(s == "drawtwo" and d2chain == 0) then
    prev_user = current_user
    cards[current_user] = cards[current_user] + 1
    current_user = current_user + way
    d2chain = d2chain + 1
  elseif(s == "drawfour" and d4chain == 0) then
    prev_user = current_user
    cards[current_user] = cards[current_user] + 1
    current_user = current_user + way
    d4chain = d4chain + 1
  end
  current_user = current_user % n
  if(current_user == 0) then current_user = n end
end
print(string.format("%d %d", prev_user, cards[prev_user]))
0