#41400: python


mountainwu14@gmail.com (吳小四)

學校 : 不指定學校
編號 : 187101
來源 : [123.193.136.130]
最後登入時間 :
2024-07-25 20:25:33
f647. 撲克牌 -- 林口高中練習題 | From: [123.193.136.130] | 發表日期 : 2024-07-24 11:13

# 初始化52張牌
deck = [
    "SA", "S2", "S3", "S4", "S5", "S6", "S7", "S8", "S9", "S10", "SJ", "SQ", "SK",
    "HA", "H2", "H3", "H4", "H5", "H6", "H7", "H8", "H9", "H10", "HJ", "HQ", "HK",
    "DA", "D2", "D3", "D4", "D5", "D6", "D7", "D8", "D9", "D10", "DJ", "DQ", "DK",
    "FA", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10", "FJ", "FQ", "FK"
]

# 讀取輸入
import sys
input = sys.stdin.read
data = input().split()
n = int(data[0])
commands = data[1:]

# 解析並執行命令
i = 0
while i < len(commands):
    cmd = int(commands[i])
    if cmd == 1:
        a = int(commands[i + 1]) - 1
        b = int(commands[i + 2])
        sub_deck = deck[a:b]
        del deck[a:b]
        deck = sub_deck + deck
        i += 3
    elif cmd == 2:
        a = int(commands[i + 1]) - 1
        b = int(commands[i + 2])
        sub_deck = deck[a:b]
        del deck[a:b]
        deck = deck + sub_deck
        i += 3
    elif cmd == 3:
        k = int(commands[i + 1])
        sub_deck = deck[-k:]
        deck = sub_deck + deck[:-k]
        i += 2
    elif cmd == 4:
        k = int(commands[i + 1])
        sub_deck = deck[:k]
        deck = deck[k:] + sub_deck
        i += 2

# 輸出最上面的5張牌
print(' '.join(deck[:5]))

 
ZeroJudge Forum