완전탐색같기도하고 dp같기도하고
import sys
t=int(sys.stdin.readline().rstrip())
for _ in range(t):
n=int(sys.stdin.readline().rstrip())
dic={}
for i in range(n):
name,type=sys.stdin.readline().rstrip().split()
if type in dic:
dic[type]+=1
else:
dic[type]=1
result=1
for i in dic:
result=result*(dic[i]+1)
print(result-1)
생각을 좀해봤는데 결국 조합개수-1하면 된다 -1한 이유는 알몸은 되면 안되기때문
완전탐색인줄 알고 엄청 고민했는데 사실 쉬운문제였다.
'IT > ps' 카테고리의 다른 글
백준 11659번 구간 합 구하기 4 (0) | 2025.02.14 |
---|---|
백준 9461 파도반 수열 (0) | 2025.02.14 |
백준 2606번 바이러스 (0) | 2025.02.14 |
백준 1003번 피보나치 함수 (0) | 2025.02.14 |
백준 1620번 포켓몬 마스터 (0) | 2025.02.13 |