結果

問題 No.769 UNOシミュレータ
ユーザー _KingdomOfMoray_KingdomOfMoray
提出日時 2019-11-27 14:41:26
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 965 ms / 2,000 ms
コード長 1,712 bytes
コンパイル時間 103 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 29,184 KB
最終ジャッジ日時 2024-05-02 00:43:11
合計ジャッジ時間 8,367 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
10,880 KB
testcase_01 AC 32 ms
10,880 KB
testcase_02 AC 31 ms
10,880 KB
testcase_03 AC 32 ms
10,752 KB
testcase_04 AC 36 ms
10,752 KB
testcase_05 AC 35 ms
10,880 KB
testcase_06 AC 37 ms
10,880 KB
testcase_07 AC 35 ms
10,752 KB
testcase_08 AC 36 ms
10,880 KB
testcase_09 AC 61 ms
11,392 KB
testcase_10 AC 61 ms
11,392 KB
testcase_11 AC 62 ms
11,264 KB
testcase_12 AC 328 ms
16,768 KB
testcase_13 AC 330 ms
16,768 KB
testcase_14 AC 327 ms
16,640 KB
testcase_15 AC 606 ms
22,912 KB
testcase_16 AC 626 ms
23,040 KB
testcase_17 AC 653 ms
22,656 KB
testcase_18 AC 965 ms
29,056 KB
testcase_19 AC 912 ms
29,184 KB
testcase_20 AC 940 ms
29,184 KB
testcase_21 AC 955 ms
29,184 KB
testcase_22 AC 32 ms
10,752 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# coding: utf-8
# Your code here!

input_params = list(map(int,input().split()))
n = input_params[0]
m = input_params[1]
card = [input() for i in range(m)]
count = [0] * n

def get_next_turn(turn, direction):
    if direction == 1:
        if turn == n:
            return 1
        else:
            return turn + 1
    else:
        if turn == 1:
            return n
        else:
            return turn -1
        
turn = 1
direction = 1
res = -1
d2_continue = 0
d4_continue = 0

for i in range(len(card)):
    if i == len(card)-1:
        res = turn
        count[turn-1] += 1
        break
        
        
    count[turn-1] += 1
    
    if card[i] == 'number':
        turn = get_next_turn(turn, direction)
    elif card[i] == 'drawtwo':
        d2_continue += 1
        
        if card[i+1] == 'drawtwo':
            turn = get_next_turn(turn, direction)
        else:
            turn = get_next_turn(turn, direction)
            
            count[turn-1] += -2 * d2_continue
            d2_continue= 0
            
            turn = get_next_turn(turn, direction)
    elif card[i] == 'drawfour':
        d4_continue += 1
        
        if card[i+1] == 'drawfour':
            turn = get_next_turn(turn, direction)
        else:
            turn = get_next_turn(turn, direction)
            
            count[turn-1] += -4 * d4_continue
            d4_continue= 0
            
            turn = get_next_turn(turn, direction)
    elif card[i] == 'skip':
        turn = get_next_turn(turn, direction)
        turn = get_next_turn(turn, direction)
    elif card[i] == 'reverse':
        direction *= -1
        turn = get_next_turn(turn, direction)
    
print('{} {}'.format(res, count[res-1]))
0