알고리즘/백준
[Python] 백준 파이썬 9375 패션왕 신해빈
dding96
2022. 10. 15. 10:34
https://www.acmicpc.net/problem/9375
9375번: 패션왕 신해빈
첫 번째 테스트 케이스는 headgear에 해당하는 의상이 hat, turban이며 eyewear에 해당하는 의상이 sunglasses이므로 (hat), (turban), (sunglasses), (hat,sunglasses), (turban,sunglasses)로 총 5가지 이다.
www.acmicpc.net
# 백준 9375 패션왕 신해빈
t = int(input())
for _ in range(t):
# 나중에 정답으로 출력할 변수 정의
ans = 1
n = int(input())
# 옷이 없으면 입을수가 없으니 0
if n == 0:
print(0)
else:
# 옷들의 종류(type)만 저장해줌.
type_list = []
for _ in range(n):
_, item_type = input().split()
type_list.append(item_type)
# 종류 중에서 유니크한 종류만 따로 저장
unique_type = list(set(type_list))
if len(unique_type) == 1:
print(n)
else:
for i in unique_type:
# 각 유니크한 종류의 갯수와 그 종류의 옷을 입지않는 경우를 더해서 순차적으로 곱해줌
type_cnt = type_list.count(i)
ans *= (type_cnt+1)
# 전부 입지 않는 경우를 빼줌
print(ans-1)