def card_value(card_id):
""" 根據牌的 id 返回對應的點數和花色 """
suits = ['S', 'H', 'D', 'C'] # 黑桃、紅心、方塊、梅花
values = ['A', '2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K']
suit = suits[card_id // 13] # 整除 13 得到花色
value = values[card_id % 13] # 取模 13 得到點數
return (suit, value)
def sort_cards(cards):
""" 根據牌的點數和花色進行排序 """
values_order = {'2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9, 'T': 10, 'J': 11, 'Q': 12, 'K': 13, 'A': 14}
suits_order = {'S': 4, 'H': 3, 'D': 2, 'C': 1}
return sorted(cards, key=lambda x: (values_order[x[1]], suits_order[x[0]]), reverse=True)
def player_key(player):
""" 根據玩家的手牌生成排序鍵值 """
cards = player[1]
values_order = {'2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9, 'T': 10, 'J': 11, 'Q': 12, 'K': 13, 'A': 14}
suits_order = {'S': 4, 'H': 3, 'D': 2, 'C': 1}
return [(values_order[card[1]], suits_order[card[0]]) for card in cards]
# 讀取輸入
t = int(input().strip()) # 測試案例數量
cases = []
for _ in range(t):
cards = list(map(int, input().strip().split()))
cases.append(cards)
# 處理每個案例
for case_num, cards in enumerate(cases, start=1):
print(f"Case {case_num}:")
players = [[] for _ in range(10)]
for i in range(50):
players[i % 10].append(card_value(cards[i]))
# 排序每個玩家的手牌
for i in range(10):
players[i] = sort_cards(players[i])
# 生成包含玩家編號和手牌的列表
players_with_index = [(i + 1, players[i]) for i in range(10)]
# 根據手牌對玩家進行排序
players_with_index.sort(key=lambda player: player_key(player), reverse=True)
# 按排名順序輸出每個玩家的牌
for player_num, player_cards in players_with_index:
player_hand = ' '.join([f'{card[0]}{card[1]}' for card in player_cards])
print(f"{player_num} {player_hand}")
1
26 31 42 28 22 25 40 30 14 1 47 19 13 5 9 10 24 6 18 38 29 0 15 2 34 50 27 37 46 7 12 8 35 4 21 49 36 39 43 20 17 23 51 44 3 41 32 45 11 16def card_value(card_id):
""" 根據牌的 id 返回對應的點數和花色 """
suits = ['S', 'H', 'D', 'C'] # 黑桃、紅心、方塊、梅花
values = ['A', '2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K']
suit = suits[card_id // 13] # 整除 13 得到花色
value = values[card_id % 13] # 取模 13 得到點數
return (suit, value)def sort_cards(cards):
""" 根據牌的點數和花色進行排序 """
values_order = {'2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9, 'T': 10, 'J': 11, 'Q': 12, 'K': 13, 'A': 14}
suits_order = {'S': 4, 'H': 3, 'D': 2, 'C': 1}
return sorted(cards, key=lambda x: (values_order[x[1]], suits_order[x[0]]), reverse=True)def player_key(player):
""" 根據玩家的手牌生成排序鍵值 """
cards = player[1]
values_order = {'2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9, 'T': 10, 'J': 11, 'Q': 12, 'K': 13, 'A': 14}
suits_order = {'S': 4, 'H': 3, 'D': 2, 'C': 1}
return [(values_order[card[1]], suits_order[card[0]]) for card in cards]# 讀取輸入
t = int(input().strip()) # 測試案例數量
cases = []for _ in range(t):
cards = list(map(int, input().strip().split()))
cases.append(cards)# 處理每個案例
for case_num, cards in enumerate(cases, start=1):
print(f"Case {case_num}:")players = [[] for _ in range(10)]
for i in range(50):
players[i % 10].append(card_value(cards[i]))# 排序每個玩家的手牌
for i in range(10):
players[i] = sort_cards(players[i])# 生成包含玩家編號和手牌的列表
players_with_index = [(i + 1, players[i]) for i in range(10)]# 根據手牌對玩家進行排序
players_with_index.sort(key=lambda player: player_key(player), reverse=True)# 按排名順序輸出每個玩家的牌
for player_num, player_cards in players_with_index:
player_hand = ' '.join([f'{card[0]}{card[1]}' for card in player_cards])
print(f"{player_num} {player_hand}")
1
26 25 47 10 29 50 12 49 17 41 31 40 19 24 0 27 8 36 23 32 42 30 13 6 15 37 35 39 51 45 28 14 5 18 2 46 4 43 44 11 22 1 9 38 34 7 21 20 3 16
def card_value(card_id):
""" 根據牌的 id 返回對應的點數和花色 """
suits = ['S', 'H', 'D', 'C'] # 黑桃、紅心、方塊、梅花
values = ['A', '2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K']
suit = suits[card_id // 13] # 整除 13 得到花色
value = values[card_id % 13] # 取模 13 得到點數
return (suit, value)def sort_cards(cards):
""" 根據牌的點數和花色進行排序 """
values_order = {'2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9, 'T': 10, 'J': 11, 'Q': 12, 'K': 13, 'A': 14}
suits_order = {'S': 4, 'H': 3, 'D': 2, 'C': 1}
return sorted(cards, key=lambda x: (values_order[x[1]], suits_order[x[0]]), reverse=True)def player_key(player):
""" 根據玩家的手牌生成排序鍵值 """
cards = player[1]
values_order = {'2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9, 'T': 10, 'J': 11, 'Q': 12, 'K': 13, 'A': 14}
suits_order = {'S': 4, 'H': 3, 'D': 2, 'C': 1}
return [(values_order[card[1]], suits_order[card[0]]) for card in cards]# 讀取輸入
t = int(input().strip()) # 測試案例數量
cases = []for _ in range(t):
cards = list(map(int, input().strip().split()))
cases.append(cards)# 處理每個案例
for case_num, cards in enumerate(cases, start=1):
print(f"Case {case_num}:")players = [[] for _ in range(10)]
for i in range(50):
players[i % 10].append(card_value(cards[i]))# 排序每個玩家的手牌
for i in range(10):
players[i] = sort_cards(players[i])# 生成包含玩家編號和手牌的列表
players_with_index = [(i + 1, players[i]) for i in range(10)]# 根據手牌對玩家進行排序
players_with_index.sort(key=lambda player: player_key(player), reverse=True)# 按排名順序輸出每個玩家的牌
for player_num, player_cards in players_with_index:
player_hand = ' '.join([f'{card[0]}{card[1]}' for card in player_cards])
print(f"{player_num} {player_hand}")