https://www.acmicpc.net/problem/9375
import sys
t = int(sys.stdin.readline())
ans=[]
for _ in range(t):
clothes = {}
cnt = 1
n = int(sys.stdin.readline())
if n ==0:
sum =0
for _ in range(n):
li = sys.stdin.readline().split()
category = li[1]
count = clothes.get(category,0) #키가 없으면 0
clothes[category] = count+1
for count in clothes.values():
cnt *= count
if len(clothes.items())>1:
cnt += n
ans.append(cnt)
for i in ans:
print(i)
=> 전체 모든 피스를 입는게 아니기 때문에 오답!
import sys
t = int(sys.stdin.readline())
ans=[]
for _ in range(t):
clothes = {}
total = 1
n = int(sys.stdin.readline())
if n ==0:
cnt =0
for _ in range(n):
li = sys.stdin.readline().split()
category = li[1]
count = clothes.get(category,0) #키가 없으면 0
clothes[category] = count+1
for item in clothes.values():
total *= (item+1)
ans.append(total-1)
for i in ans:
print(i)