結果

問題 No.769 UNOシミュレータ
ユーザー maspymaspy
提出日時 2020-05-01 18:42:18
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 289 ms / 2,000 ms
コード長 1,027 bytes
コンパイル時間 265 ms
コンパイル使用メモリ 10,804 KB
実行使用メモリ 12,572 KB
最終ジャッジ日時 2023-08-26 01:20:01
合計ジャッジ時間 3,646 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 13 ms
7,728 KB
testcase_01 AC 14 ms
7,808 KB
testcase_02 AC 12 ms
7,800 KB
testcase_03 AC 13 ms
7,908 KB
testcase_04 AC 14 ms
8,244 KB
testcase_05 AC 13 ms
8,204 KB
testcase_06 AC 13 ms
7,960 KB
testcase_07 AC 13 ms
8,308 KB
testcase_08 AC 14 ms
8,312 KB
testcase_09 AC 22 ms
8,436 KB
testcase_10 AC 21 ms
8,384 KB
testcase_11 AC 22 ms
8,428 KB
testcase_12 AC 104 ms
9,580 KB
testcase_13 AC 103 ms
9,528 KB
testcase_14 AC 98 ms
9,664 KB
testcase_15 AC 185 ms
10,964 KB
testcase_16 AC 188 ms
10,996 KB
testcase_17 AC 189 ms
10,956 KB
testcase_18 AC 286 ms
12,524 KB
testcase_19 AC 289 ms
12,572 KB
testcase_20 AC 269 ms
12,488 KB
testcase_21 AC 271 ms
12,472 KB
testcase_22 AC 13 ms
7,844 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, M = map(int, readline().split())
LOG = read().decode()

LOG = LOG.replace('number', 'n')
LOG = LOG.replace('skip', 's')
LOG = LOG.replace('drawtwo', '2')
LOG = LOG.replace('drawfour', '4')
LOG = LOG.replace('reverse', 'r')
LOG = LOG.split()

num = [0] * N
player = -1
dx = 1
draw_2 = 0
draw_4 = 0
skip_flag = False
for L in LOG:
    if skip_flag:
        player += dx
        skip_flag = False
    player += dx
    player %= N
    if draw_2 and L != '2':
        num[player] += 2 * draw_2
        draw_2 = 0
        player += dx
    if draw_4 and L != '4':
        num[player] += 4 * draw_4
        draw_4 = 0
        player += dx
    player %= N
    num[player] -= 1
    if L == 's':
        skip_flag = True
    elif L == 'n':
        pass
    elif L == 'r':
        dx *= -1
    elif L == '2':
        draw_2 += 1
    elif L == '4':
        draw_4 += 1

player %= N
x = -num[player]
print(player + 1, x)
0