結果

問題 No.769 UNOシミュレータ
ユーザー terasa
提出日時 2022-06-09 21:45:13
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 180 ms / 2,000 ms
コード長 1,546 bytes
コンパイル時間 328 ms
コンパイル使用メモリ 82,556 KB
実行使用メモリ 78,732 KB
最終ジャッジ日時 2024-09-21 05:39:19
合計ジャッジ時間 4,240 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
import pypyjit
import itertools
import heapq
import math
from collections import deque, defaultdict
import bisect
import random

input = sys.stdin.readline
sys.setrecursionlimit(10 ** 6)
pypyjit.set_param('max_unroll_recursion=-1')


def index_lt(a, x):
    'return largest index s.t. A[i] < x or -1 if it does not exist'
    return bisect.bisect_left(a, x) - 1


def index_le(a, x):
    'return largest index s.t. A[i] <= x or -1 if it does not exist'
    return bisect.bisect_right(a, x) - 1


def index_gt(a, x):
    'return smallest index s.t. A[i] > x or len(a) if it does not exist'
    return bisect.bisect_right(a, x)


def index_ge(a, x):
    'return smallest index s.t. A[i] >= x or len(a) if it does not exist'
    return bisect.bisect_left(a, x)


def generate(k):
    return random.sample(range(26), k)


N, M = map(int, input().split())


def next():
    global id
    if reverse is True:
        id = (id - 1) % N
    else:
        id = (id + 1) % N


id = 0
reverse = False
cnt = [0] * N
acc2 = 0
acc4 = 0
for i in range(M):
    l = input()[:-1]
    if acc2 > 0 and l != 'drawtwo':
        cnt[id] += 2 * acc2
        acc2 = 0
        next()
    if acc4 > 0 and l != 'drawfour':
        cnt[id] += 4 * acc4
        acc4 = 0
        next()

    cnt[id] -= 1
    if i == M - 1:
        print(id + 1, -cnt[id])
    if l == 'number':
        pass
    elif l == 'drawtwo':
        acc2 += 1
    elif l == 'drawfour':
        acc4 += 1
    elif l == 'skip':
        next()
    else:
        reverse = not reverse

    next()
0