백준 9375번: 패션왕 신해빈 #Python

ColorlessDia·2025년 3월 16일

algorithm/baekjoon

목록 보기
483/813
import sys

input = sys.stdin.readline

T = int(input())

for _ in range(T):
    N = int(input())

    wear_dict = dict()

    for _ in range(N):
        wear_name, wear_type = input().rstrip().split()

        if wear_type not in wear_dict:
            wear_dict[wear_type] = {}
        
        wear_dict[wear_type][wear_name] = 1
    
    count_list = [len(v) for v in wear_dict.values()]
    total = 1

    for count in count_list:
        total *= count + 1
    
    print(total - 1)

0개의 댓글