[알고리즘/백준]9375번 : 패션왕 신해빈(python)

유현민·2022년 9월 7일
0

알고리즘

목록 보기
246/253

경우의 수는 headgear -> (hat, turban, x)
eyewear -> (sunglasses, x)
두 경우를 곱해서 전부 입지 않은 경우를 빼면 정답이다.

=> (headgear + 1) * (eyewear + 1) - 1

from collections import defaultdict


for _ in range(int(input())):
    n = int(input())
    a = defaultdict(int)
    ans = 1
    for _ in range(n):
        name, op = input().split()
        a[op] += 1
    for i in a:
        ans *= (a[i] + 1)
    print(ans - 1)
profile
smilegate megaport infra

0개의 댓글