목차

패션왕 신해빈

ps
링크acmicpc.net/…
출처BOJ
문제 번호9375
문제명패션왕 신해빈
레벨실버 3
분류

애드혹

시간복잡도O(t*n*l)
인풋사이즈t<=100, n<=30, l<=20
사용한 언어Python
제출기록32636KB / 124ms
최고기록52ms
해결날짜2021/07/26

풀이

코드

"""Solution code for "BOJ 9375. 패션왕 신해빈".

- Problem link: https://www.acmicpc.net/problem/9375
- Solution link: http://www.teferi.net/ps/problems/boj/9375
"""

import collections
import functools
import operator


def main():
    t = int(input())
    for _ in range(t):
        n = int(input())
        clothes = [input().split() for _ in range(n)]
        counter = collections.Counter(category for name, category in clothes)
        print(functools.reduce(operator.mul,
                               (v + 1 for v in counter.values()), 1) - 1)


if __name__ == '__main__':
    main()