結果

問題 No.769 UNOシミュレータ
ユーザー takumi152takumi152
提出日時 2019-05-28 18:30:54
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 671 ms / 2,000 ms
コード長 1,348 bytes
コンパイル時間 281 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 29,312 KB
最終ジャッジ日時 2024-05-02 00:35:33
合計ジャッジ時間 6,323 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
10,752 KB
testcase_01 AC 26 ms
10,752 KB
testcase_02 AC 26 ms
10,752 KB
testcase_03 AC 26 ms
10,752 KB
testcase_04 AC 28 ms
10,880 KB
testcase_05 AC 28 ms
10,752 KB
testcase_06 AC 28 ms
10,880 KB
testcase_07 AC 27 ms
10,880 KB
testcase_08 AC 27 ms
10,880 KB
testcase_09 AC 45 ms
11,392 KB
testcase_10 AC 47 ms
11,392 KB
testcase_11 AC 48 ms
11,392 KB
testcase_12 AC 232 ms
16,768 KB
testcase_13 AC 239 ms
16,768 KB
testcase_14 AC 233 ms
16,640 KB
testcase_15 AC 457 ms
22,912 KB
testcase_16 AC 459 ms
22,912 KB
testcase_17 AC 450 ms
22,784 KB
testcase_18 AC 669 ms
29,312 KB
testcase_19 AC 643 ms
29,184 KB
testcase_20 AC 671 ms
29,312 KB
testcase_21 AC 646 ms
29,056 KB
testcase_22 AC 31 ms
10,752 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
    buf = input()
    buflist = buf.split()
    N = int(buflist[0])
    M = int(buflist[1])
    cardlog = []
    for i in range(M):
        buf = input()
        cardlog.append(buf)
    card_count = []
    for i in range(N):
        card_count.append(0)
    current_turn = 0
    reverse = False
    lastlog = ''
    draw_stack = 0
    for log in cardlog:
        if draw_stack > 0 and lastlog != log:
            card_count[current_turn] -= draw_stack
            draw_stack = 0
            current_turn = next_turn(current_turn, reverse, N)
        card_count[current_turn] += 1
        if log == 'number':
            pass
        elif log == 'drawtwo':
            draw_stack += 2
        elif log == 'drawfour':
            draw_stack += 4
        elif log == 'skip':
            current_turn = next_turn(current_turn, reverse, N)
        elif log == 'reverse':
            reverse = not reverse
        lastlog = log
        current_turn = next_turn(current_turn, reverse, N)
    winner = next_turn(current_turn, not reverse, N)
    if lastlog == 'skip':
        winner = next_turn(winner, not reverse, N)
    print(winner + 1, card_count[winner])

def next_turn(current_turn, reverse, N):
    if reverse:
        return (current_turn - 1) % N
    else:
        return (current_turn + 1) % N

if __name__ == '__main__':
    main()
0